Przeglądaj źródła

Optionally set a separate xmpp password

Bob Mottram 9 lat temu
rodzic
commit
58fc0619dd
1 zmienionych plików z 16 dodań i 4 usunięć
  1. 16
    4
      src/freedombone

+ 16
- 4
src/freedombone Wyświetl plik

304
 
304
 
305
 # Directory where XMPP settings are stored
305
 # Directory where XMPP settings are stored
306
 XMPP_DIRECTORY="/var/lib/prosody"
306
 XMPP_DIRECTORY="/var/lib/prosody"
307
+XMPP_PASSWORD=
307
 
308
 
308
 # file containing a list of remote locations to backup to
309
 # file containing a list of remote locations to backup to
309
 # Format: [username@friendsdomain//home/username] [ssh_password]
310
 # Format: [username@friendsdomain//home/username] [ssh_password]
1038
         if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
1039
         if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
1039
             cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
1040
             cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
1040
         fi
1041
         fi
1042
+        if grep -q "XMPP_PASSWORD" $CONFIGURATION_FILE; then
1043
+            XMPP_PASSWORD=$(grep "XMPP_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1044
+        fi
1041
         if grep -q "RSS_READER_REPO" $CONFIGURATION_FILE; then
1045
         if grep -q "RSS_READER_REPO" $CONFIGURATION_FILE; then
1042
             RSS_READER_REPO=$(grep "RSS_READER_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1046
             RSS_READER_REPO=$(grep "RSS_READER_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1043
         fi
1047
         fi
7428
     fi
7432
     fi
7429
 
7433
 
7430
     if ! grep -q "Your XMPP password is" /home/$MY_USERNAME/README; then
7434
     if ! grep -q "Your XMPP password is" /home/$MY_USERNAME/README; then
7431
-        if [ -f $IMAGE_PASSWORD_FILE ]; then
7432
-            XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
7433
-        else
7434
-            XMPP_PASSWORD="$(openssl rand -base64 8)"
7435
+        if [ ${#XMPP_PASSWORD} -lt 8 ]; then
7436
+            if [ -f $IMAGE_PASSWORD_FILE ]; then
7437
+                XMPP_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
7438
+            else
7439
+                XMPP_PASSWORD="$(openssl rand -base64 8)"
7440
+            fi
7435
         fi
7441
         fi
7436
         prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
7442
         prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
7437
         echo '' >> /home/$MY_USERNAME/README
7443
         echo '' >> /home/$MY_USERNAME/README
7478
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7484
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7479
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7485
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7480
         echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
7486
         echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
7487
+        if [ ${#XMPP_PASSWORD} -gt 2 ]; then
7488
+            echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
7489
+        fi
7481
     fi
7490
     fi
7482
 
7491
 
7483
     if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
7492
     if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
7499
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7508
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7500
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7509
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7501
         echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
7510
         echo 'priority.dnd=0' >> $XMPP_CLIENT_ACCOUNTS
7511
+        if [ ${#XMPP_PASSWORD} -gt 2 ]; then
7512
+            echo "password=$XMPP_PASSWORD" >> $XMPP_CLIENT_ACCOUNTS
7513
+        fi
7502
     fi
7514
     fi
7503
 
7515
 
7504
     if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then
7516
     if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then