Przeglądaj źródła

mediagoblin daemon

Bob Mottram 8 lat temu
rodzic
commit
1f886564dc
1 zmienionych plików z 31 dodań i 2 usunięć
  1. 31
    2
      src/freedombone-app-mediagoblin

+ 31
- 2
src/freedombone-app-mediagoblin Wyświetl plik

@@ -39,6 +39,7 @@ MEDIAGOBLIN_CODE=
39 39
 MEDIAGOBLIN_ONION_PORT=8108
40 40
 MEDIAGOBLIN_REPO="http://git.savannah.gnu.org/r/mediagoblin.git"
41 41
 MEDIAGOBLIN_BASE_DIR=/var/www/mediagoblin.local/htdocs
42
+MEDIAGOBLIN_PORT=26543
42 43
 
43 44
 mediagoblin_variables=(ONION_ONLY
44 45
                        MY_USERNAME
@@ -160,6 +161,10 @@ function remove_mediagoblin {
160 161
         return
161 162
     fi
162 163
     MEDIAGOBLIN_BASE_DIR=/var/www/$MEDIAGOBLIN_DOMAIN_NAME/htdocs
164
+    systemctl stop mediagoblin
165
+    systemctl disable mediagoblin
166
+    rm /etc/systemd/system/mediagoblin.service
167
+
163 168
     function_check remove_onion_service
164 169
     remove_onion_service mediagoblin ${MEDIAGOBLIN_ONION_PORT}
165 170
     nginx_dissite $MEDIAGOBLIN_DOMAIN_NAME
@@ -193,7 +198,7 @@ function install_mediagoblin {
193 198
     install_nodejs mediagoblin
194 199
 
195 200
     apt-get install -yq python python-dev python-lxml python-imaging python-virtualenv
196
-    apt-get install -yq automake perl
201
+    apt-get install -yq automake perl sqlite
197 202
     useradd -c "GNU MediaGoblin system account" -d /var/lib/mediagoblin -m -r -g www-data mediagoblin
198 203
     groupadd mediagoblin
199 204
     usermod --append -G mediagoblin mediagoblin
@@ -287,7 +292,7 @@ function install_mediagoblin {
287 292
         echo '    }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
288 293
         echo '' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
289 294
         echo '    location / {' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
290
-        echo '        fastcgi_pass 127.0.0.1:26543;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
295
+        echo "        fastcgi_pass 127.0.0.1:$MEDIAGOBLIN_PORT;" >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
291 296
         echo '        include /etc/nginx/fastcgi_params;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
292 297
         echo '        fastcgi_param PATH_INFO $fastcgi_script_name;' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
293 298
         echo '        fastcgi_param SCRIPT_NAME "";' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
@@ -343,6 +348,30 @@ function install_mediagoblin {
343 348
     echo '    }' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
344 349
     echo '}' >> /etc/nginx/sites-available/$MEDIAGOBLIN_DOMAIN_NAME
345 350
 
351
+    su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg dbupdate" - mediagoblin
352
+    su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg adduser --username $MY_USERNAME --password admin $MEDIAGOBLIN_ADMIN_PASSWORD" - mediagoblin
353
+    su -c "cd $MEDIAGOBLIN_BASE_DIR/mediagoblin/ && bin/gmg makeadmin admin" - mediagoblin
354
+
355
+    echo '[Unit]' > /etc/systemd/system/mediagoblin.service
356
+    echo 'Description=Media service' >> /etc/systemd/system/mediagoblin.service
357
+    echo 'Requires=network.target' >> /etc/systemd/system/mediagoblin.service
358
+    echo 'After=network.target' >> /etc/systemd/system/mediagoblin.service
359
+    echo '' >> /etc/systemd/system/mediagoblin.service
360
+    echo '[Service]' >> /etc/systemd/system/mediagoblin.service
361
+    echo 'Type=simple' >> /etc/systemd/system/mediagoblin.service
362
+    echo 'User=mediagoblin' >> /etc/systemd/system/mediagoblin.service
363
+    echo "WorkingDirectory=$MEDIAGOBLIN_BASE_DIR/mediagoblin/" >> /etc/systemd/system/mediagoblin.service
364
+    echo "ExecStart=$MEDIAGOBLIN_BASE_DIR/mediagoblin/lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=$MEDIAGOBLIN_PORT" >> /etc/systemd/system/mediagoblin.service
365
+    echo 'Restart=always' >> /etc/systemd/system/mediagoblin.service
366
+    echo 'RestartSec=10' >> /etc/systemd/system/mediagoblin.service
367
+    echo '' >> /etc/systemd/system/mediagoblin.service
368
+    echo '[Install]' >> /etc/systemd/system/mediagoblin.service
369
+    echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mediagoblin.service
370
+    chmod +x /etc/systemd/system/mediagoblin.service
371
+
372
+    systemctl enable mediagoblin
373
+    systemctl daemon-reload
374
+    systemctl start mediagoblin
346 375
 
347 376
     function_check create_site_certificate
348 377
     create_site_certificate $MEDIAGOBLIN_DOMAIN_NAME