Browse Source

Turn smilodon environment into a script

Bob Mottram 7 years ago
parent
commit
8e3a997fcb
1 changed files with 16 additions and 8 deletions
  1. 16
    8
      src/freedombone-app-smilodon

+ 16
- 8
src/freedombone-app-smilodon View File

@@ -328,6 +328,19 @@ function install_smilodon {
328 328
         SMILODON_SECRET_KEY="$(create_password 30)$(create_password 30)$(create_password 30)$(create_password 30)"
329 329
     fi
330 330
 
331
+    echo '#!/bin/bash' > ${SMILODON_PATH}/run_smilodon.sh
332
+    echo "cd ${SMILODON_PATH}" >> ${SMILODON_PATH}/run_smilodon.sh
333
+    echo "export smilodon_domain_name=$SMILODON_ONION_HOSTNAME" >> ${SMILODON_PATH}/run_smilodon.sh
334
+    echo "export secret_key='$SMILODON_SECRET_KEY'" >> ${SMILODON_PATH}/run_smilodon.sh
335
+    echo "export mongodb_username='smilodon'" >> ${SMILODON_PATH}/run_smilodon.sh
336
+    echo "export mongodb_password='$SMILODON_ADMIN_PASSWORD'" >> ${SMILODON_PATH}/run_smilodon.sh
337
+    echo "export smilodon_admin_address=$MY_EMAIL_ADDRESS" >> ${SMILODON_PATH}/run_smilodon.sh
338
+    echo "export MAIL_SERVER='localhost'" >> ${SMILODON_PATH}/run_smilodon.sh
339
+    echo "export MAIL_PORT=25" >> ${SMILODON_PATH}/run_smilodon.sh
340
+    echo "${SMILODON_PATH}/run_smilodon.sh" >> ${SMILODON_PATH}/run_smilodon.sh
341
+    chmod +x ${SMILODON_PATH}/run_smilodon.sh
342
+    chown smilodon:smilodon ${SMILODON_PATH}/run_smilodon.sh
343
+
331 344
     echo '[Unit]' > /etc/systemd/system/smilodon.service
332 345
     echo 'Description=Smilodon ActivityPub messenger' >> /etc/systemd/system/smilodon.service
333 346
     echo 'After=network.target mongodb.service' >> /etc/systemd/system/smilodon.service
@@ -337,14 +350,9 @@ function install_smilodon {
337 350
     echo 'User=smilodon' >> /etc/systemd/system/smilodon.service
338 351
     echo 'Group=smilodon' >> /etc/systemd/system/smilodon.service
339 352
     echo "WorkingDirectory=${SMILODON_PATH}/" >> /etc/systemd/system/smilodon.service
340
-    echo "ExecStart=/usr/bin/python3 run.py" >> /etc/systemd/system/smilodon.service
341
-    echo "Environment=smilodon_domain_name=$SMILODON_ONION_HOSTNAME" >> /etc/systemd/system/smilodon.service
342
-    echo "Environment=secret_key='$SMILODON_SECRET_KEY'" >> /etc/systemd/system/smilodon.service
343
-    echo "Environment=mongodb_username='smilodon'" >> /etc/systemd/system/smilodon.service
344
-    echo "Environment=mongodb_password='$SMILODON_ADMIN_PASSWORD'" >> /etc/systemd/system/smilodon.service
345
-    echo "Environment=smilodon_admin_address=$MY_EMAIL_ADDRESS" >> /etc/systemd/system/smilodon.service
346
-    echo "Environment=MAIL_SERVER='localhost'" >> /etc/systemd/system/smilodon.service
347
-    echo "Environment=MAIL_PORT=25" >> /etc/systemd/system/smilodon.service
353
+    echo "ExecStart=${SMILODON_PATH}/run_smilodon.sh" >> /etc/systemd/system/smilodon.service
354
+    echo 'Restart=on-failure' >> /etc/systemd/system/smilodon.service
355
+    echo 'RestartSec=10' >> /etc/systemd/system/smilodon.service
348 356
     echo '' >> /etc/systemd/system/smilodon.service
349 357
     echo '[Install]' >> /etc/systemd/system/smilodon.service
350 358
     echo 'WantedBy=multi-user.target' >> /etc/systemd/system/smilodon.service