Просмотр исходного кода

Optionally set a separate xmpp password

Bob Mottram 9 лет назад
Родитель
Сommit
58fc0619dd
1 измененных файлов: 16 добавлений и 4 удалений
  1. 16
    4
      src/freedombone

+ 16
- 4
src/freedombone Просмотреть файл

@@ -304,6 +304,7 @@ MARIADB_PASSWORD=
304 304
 
305 305
 # Directory where XMPP settings are stored
306 306
 XMPP_DIRECTORY="/var/lib/prosody"
307
+XMPP_PASSWORD=
307 308
 
308 309
 # file containing a list of remote locations to backup to
309 310
 # Format: [username@friendsdomain//home/username] [ssh_password]
@@ -1038,6 +1039,9 @@ function read_configuration {
1038 1039
         if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
1039 1040
             cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
1040 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 1045
         if grep -q "RSS_READER_REPO" $CONFIGURATION_FILE; then
1042 1046
             RSS_READER_REPO=$(grep "RSS_READER_REPO" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
1043 1047
         fi
@@ -7428,10 +7432,12 @@ function install_xmpp {
7428 7432
     fi
7429 7433
 
7430 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 7441
         fi
7436 7442
         prosodyctl register $MY_USERNAME $DEFAULT_DOMAIN_NAME $XMPP_PASSWORD
7437 7443
         echo '' >> /home/$MY_USERNAME/README
@@ -7478,6 +7484,9 @@ function install_xmpp_client {
7478 7484
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7479 7485
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7480 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 7490
     fi
7482 7491
 
7483 7492
     if [ -f /var/lib/tor/hidden_service_xmpp/hostname ]; then
@@ -7499,6 +7508,9 @@ function install_xmpp_client {
7499 7508
         echo 'priority.away=0' >> $XMPP_CLIENT_ACCOUNTS
7500 7509
         echo 'priority.xa=0' >> $XMPP_CLIENT_ACCOUNTS
7501 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 7514
     fi
7503 7515
 
7504 7516
     if [ ! -d /home/$MY_USERNAME/.config/profanity ]; then