From 1538234bf1d461ac8d5362ae3bf6e6c81404f9cd Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Tue, 20 Sep 2016 21:38:43 +0100 Subject: [PATCH] Upate client to enable Parabola/Arch users --- src/freedombone-client | 56 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/src/freedombone-client b/src/freedombone-client index 787ce416..33215634 100755 --- a/src/freedombone-client +++ b/src/freedombone-client @@ -58,23 +58,44 @@ SSH_HOST_KEY_ALGORITHMS=$(cat $MAIN_PROJECT_FILE | grep 'SSH_HOST_KEY_ALGORITHMS REFRESH_GPG_KEYS_HOURS=2 function global_rate_limit { - sudo cp /etc/sysctl.conf ~/sysctl.conf + SYSCTL_FILE=/etc/sysctl.conf + if [ -f /usr/bin/pacman ]; then + SYSCTL_FILE=/etc/sysctl.d/99-sysctl.conf + fi + if [ ! -f $SYSCTL_FILE ]; then + sudo touch $SYSCTL_FILE + fi + + sudo cp $SYSCTL_FILE ~/sysctl.conf + if [ ! -f /usr/bin/pacman ]; then + sudo chown $CURR_USER:$CURR_USER ~/sysctl.conf + else + sudo chown $CURR_USER:users ~/sysctl.conf + fi if ! grep -q "tcp_challenge_ack_limit" ~/sysctl.conf; then echo 'net.ipv4.tcp_challenge_ack_limit = 999999999' >> ~/sysctl.conf else sed -i 's|net.ipv4.tcp_challenge_ack_limit.*|net.ipv4.tcp_challenge_ack_limit = 999999999|g' ~/sysctl.conf fi - sudo cp ~/sysctl.conf /etc/sysctl.conf + sudo cp ~/sysctl.conf $SYSCTL_FILE sudo rm ~/sysctl.conf sudo sysctl -p } function refresh_gpg_keys { if [ ! -f /usr/bin/gpg ]; then - sudo apt-get -y install gnupg + if [ ! -f /usr/bin/pacman ]; then + sudo apt-get -y install gnupg + else + sudo pacman -S --noconfirm gnupg + fi fi sudo cp /etc/crontab ~/temp_crontab - sudo chown $CURR_USER:$CURR_USER ~/temp_crontab + if [ ! -f /usr/bin/pacman ]; then + sudo chown $CURR_USER:$CURR_USER ~/temp_crontab + else + sudo chown $CURR_USER:users ~/temp_crontab + fi if ! grep -q "gpg --refresh-keys" ~/temp_crontab; then echo "0 */$REFRESH_GPG_KEYS_HOURS * * * $CURR_USER /usr/bin/gpg --refresh-keys > /dev/null" >> ~/temp_crontab sudo cp ~/temp_crontab /etc/crontab @@ -97,7 +118,11 @@ function configure_ssh_client { sudo sed -i "s/# MACs.*/ MACs $SSH_MACS/g" /etc/ssh/ssh_config if ! grep -q "HostKeyAlgorithms" /etc/ssh/ssh_config; then sudo cp /etc/ssh/ssh_config ~/ssh_config - sudo chown $CURR_USER:$CURR_USER ~/ssh_config + if [ ! -f /usr/bin/pacman ]; then + sudo chown $CURR_USER:$CURR_USER ~/ssh_config + else + sudo chown $CURR_USER:users ~/ssh_config + fi echo " HostKeyAlgorithms $SSH_HOST_KEY_ALGORITHMS" >> ~/ssh_config sudo mv ~/ssh_config /etc/ssh/ssh_config sudo chown root:root /etc/ssh/ssh_config @@ -105,7 +130,11 @@ function configure_ssh_client { sudo sed -i "s/Ciphers.*/Ciphers $SSH_CIPHERS/g" /etc/ssh/ssh_config if ! grep -q "Ciphers " /etc/ssh/ssh_config; then sudo cp /etc/ssh/ssh_config ~/ssh_config - sudo chown $CURR_USER:$CURR_USER ~/ssh_config + if [ ! -f /usr/bin/pacman ]; then + sudo chown $CURR_USER:$CURR_USER ~/ssh_config + else + sudo chown $CURR_USER:users ~/ssh_config + fi echo " Ciphers $SSH_CIPHERS" >> ~/ssh_config sudo mv ~/ssh_config /etc/ssh/ssh_config sudo chown root:root /etc/ssh/ssh_config @@ -113,7 +142,11 @@ function configure_ssh_client { sudo sed -i "s/MACs.*/MACs $SSH_MACS/g" /etc/ssh/ssh_config if ! grep -q "MACs " /etc/ssh/ssh_config; then sudo cp /etc/ssh/ssh_config ~/ssh_config - sudo chown $CURR_USER:$CURR_USER ~/ssh_config + if [ ! -f /usr/bin/pacman ]; then + sudo chown $CURR_USER:$CURR_USER ~/ssh_config + else + sudo chown $CURR_USER:users ~/ssh_config + fi echo " MACs $SSH_MACS" >> ~/ssh_config sudo mv ~/ssh_config /etc/ssh/ssh_config sudo chown root:root /etc/ssh/ssh_config @@ -156,6 +189,9 @@ function configure_ssh_client { } function configure_monkeysphere { + if [ -f /usr/bin/pacman ]; then + return + fi sudo apt-get -y install tor connect-proxy monkeysphere } @@ -204,7 +240,11 @@ global_rate_limit configure_monkeysphere if [[ $MESH_CLIENT_INSTALL == $'yes' || $MESH_CLIENT_INSTALL == $'y' || $MESH_CLIENT_INSTALL == $'on' ]]; then echo $'Installing mesh packages' - sudo apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd + if [ ! -f /usr/bin/pacman ]; then + sudo apt-get -y install avahi-utils avahi-autoipd avahi-dnsconfd + else + sudo pacman -S --noconfirm avahi + fi sudo ${PROJECT_NAME}-mesh-install -f tox_node sudo ${PROJECT_NAME}-mesh-install -f toxic ${PROJECT_NAME}-mesh-install -f qtox