Fix systemd daemons for mediagoblin

This commit is contained in:
Bob Mottram 2016-03-31 21:24:48 +01:00
parent 0c94e37ed1
commit 0417500f6d
1 changed files with 166 additions and 116 deletions

View File

@ -9622,10 +9622,32 @@ function install_mediagoblin {
mkdir $MEDIAGOBLIN_WORKING_DIRECTORY/user_dev mkdir $MEDIAGOBLIN_WORKING_DIRECTORY/user_dev
fi fi
chmod 750 $MEDIAGOBLIN_WORKING_DIRECTORY/user_dev chmod 750 $MEDIAGOBLIN_WORKING_DIRECTORY/user_dev
easy_install flup su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade flup" - mediagoblin
if [ ! "$?" = "0" ]; then su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade billiard" - mediagoblin
exit 83527 su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade Paste" - mediagoblin
fi su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade amqp" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade anyjson" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade py-bcrypt" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade wtforms" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade python-dateutil" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade alembic" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade waitress" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade imagesize" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade alabaster" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade snowballstemmer" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade docutils" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade Pygments" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade beautifulsoup4" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade WebOb" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade py" - mediagoblin
su -c "cd $MEDIAGOBLIN_WORKING_DIRECTORY && ./bin/easy_install --upgrade execnet" - mediagoblin
# create some directories
mkdir /var/log/mediagoblin
chown -hR mediagoblin:www-data /var/log/mediagoblin
mkdir /var/run/mediagoblin
chown -hR mediagoblin:www-data /var/run/mediagoblin
if [ ! -f $MEDIAGOBLIN_WORKING_DIRECTORY/mediagoblin.ini ]; then if [ ! -f $MEDIAGOBLIN_WORKING_DIRECTORY/mediagoblin.ini ]; then
echo $'mediagoblin.ini not found' echo $'mediagoblin.ini not found'
exit 737529 exit 737529
@ -9638,31 +9660,59 @@ function install_mediagoblin {
cp -av mediagoblin.ini mediagoblin_local.ini cp -av mediagoblin.ini mediagoblin_local.ini
cp -av paste.ini paste_local.ini cp -av paste.ini paste_local.ini
# TODO configure ini files
chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY chown -hR mediagoblin:www-data $MEDIAGOBLIN_WORKING_DIRECTORY
# init with systemd # init with systemd
echo '[Unit]' > /etc/systemd/system/mediagoblin.service echo '[Unit]' > /etc/systemd/system/mediagoblin-celeryd.service
echo 'Description=Mediagoblin (Media Server)' >> /etc/systemd/system/mediagoblin.service echo 'Description=Mediagoblin Celeryd' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'After=syslog.target' >> /etc/systemd/system/mediagoblin.service echo 'After=syslog.target' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'After=network.target' >> /etc/systemd/system/mediagoblin.service echo 'After=network.target' >> /etc/systemd/system/mediagoblin-celeryd.service
#echo 'After=postgresql.service' >> /etc/systemd/system/mediagoblin.service echo '' >> /etc/systemd/system/mediagoblin-celeryd.service
echo '' >> /etc/systemd/system/mediagoblin.service echo '[Service]' >> /etc/systemd/system/mediagoblin-celeryd.service
echo '[Service]' >> /etc/systemd/system/mediagoblin.service echo 'User=mediagoblin' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'Type=simple' >> /etc/systemd/system/mediagoblin.service echo 'Group=mediagoblin' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'User=mediagoblin' >> /etc/systemd/system/mediagoblin.service echo 'Type=simple' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'Group=mediagoblin' >> /etc/systemd/system/mediagoblin.service echo "WorkingDirectory=$MEDIAGOBLIN_WORKING_DIRECTORY" >> /etc/systemd/system/mediagoblin-celeryd.service
echo "WorkingDirectory=$MEDIAGOBLIN_WORKING_DIRECTORY" >> /etc/systemd/system/mediagoblin.service echo "Environment=MEDIAGOBLIN_CONFIG=$MEDIAGOBLIN_WORKING_DIRECTORY/mediagoblin_local.ini \\" >> /etc/systemd/system/mediagoblin-celeryd.service
echo "ExecStart=$MEDIAGOBLIN_WORKING_DIRECTORY/lazyserver.sh --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543" >> /etc/systemd/system/mediagoblin.service echo ' CELERY_CONFIG_MODULE=mediagoblin.init.celery.from_celery' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'Restart=always' >> /etc/systemd/system/mediagoblin.service echo "ExecStart=$MEDIAGOBLIN_WORKING_DIRECTORY/bin/celery worker \\" >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'Environment="USER=mediagoblin","HOME=/var/lib/mediagoblin"' >> /etc/systemd/system/mediagoblin.service echo ' --logfile=/var/log/mediagoblin/celery.log \' >> /etc/systemd/system/mediagoblin-celeryd.service
echo '' >> /etc/systemd/system/mediagoblin.service echo ' --loglevel=INFO' >> /etc/systemd/system/mediagoblin-celeryd.service
echo '[Install]' >> /etc/systemd/system/mediagoblin.service echo 'PIDFile=/var/run/mediagoblin/mediagoblin-celeryd.pid' >> /etc/systemd/system/mediagoblin-celeryd.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mediagoblin.service echo '' >> /etc/systemd/system/mediagoblin-celeryd.service
systemctl daemon-reload echo '[Install]' >> /etc/systemd/system/mediagoblin-celeryd.service
systemctl enable mediagoblin echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mediagoblin-celeryd.service
systemctl start mediagoblin
echo '[Unit]' > /etc/systemd/system/mediagoblin-paster.service
echo 'Description=Mediagoblin' >> /etc/systemd/system/mediagoblin-paster.service
echo 'After=syslog.target' >> /etc/systemd/system/mediagoblin-paster.service
echo 'After=network.target' >> /etc/systemd/system/mediagoblin-paster.service
echo '' >> /etc/systemd/system/mediagoblin-paster.service
echo '[Service]' >> /etc/systemd/system/mediagoblin-paster.service
echo 'Type=forking' >> /etc/systemd/system/mediagoblin-paster.service
echo 'User=mediagoblin' >> /etc/systemd/system/mediagoblin-paster.service
echo 'Group=mediagoblin' >> /etc/systemd/system/mediagoblin-paster.service
echo 'Environment=CELERY_ALWAYS_EAGER=false' >> /etc/systemd/system/mediagoblin-paster.service
echo "WorkingDirectory=$MEDIAGOBLIN_WORKING_DIRECTORY" >> /etc/systemd/system/mediagoblin-paster.service
echo "ExecStart=$MEDIAGOBLIN_WORKING_DIRECTORY/bin/paster serve \\" >> /etc/systemd/system/mediagoblin-paster.service
echo " $MEDIAGOBLIN_WORKING_DIRECTORY/paste_local.ini \\" >> /etc/systemd/system/mediagoblin-paster.service
echo ' --pid-file=/var/run/mediagoblin/mediagoblin.pid \' >> /etc/systemd/system/mediagoblin-paster.service
echo ' --log-file=/var/log/mediagoblin/mediagoblin.log \' >> /etc/systemd/system/mediagoblin-paster.service
echo ' --daemon \' >> /etc/systemd/system/mediagoblin-paster.service
echo ' --server-name=fcgi fcgi_host=127.0.0.1 fcgi_port=26543' >> /etc/systemd/system/mediagoblin-paster.service
echo "ExecStop=$MEDIAGOBLIN_WORKING_DIRECTORY/bin/paster serve \\" >> /etc/systemd/system/mediagoblin-paster.service
echo ' --pid-file=/var/run/mediagoblin/mediagoblin.pid \' >> /etc/systemd/system/mediagoblin-paster.service
echo " $MEDIAGOBLIN_WORKING_DIRECTORY/paste_local.ini stop" >> /etc/systemd/system/mediagoblin-paster.service
echo 'PIDFile=/var/run/mediagoblin/mediagoblin.pid' >> /etc/systemd/system/mediagoblin-paster.service
echo '' >> /etc/systemd/system/mediagoblin-paster.service
echo '[Install]' >> /etc/systemd/system/mediagoblin-paster.service
echo 'WantedBy=multi-user.target' >> /etc/systemd/system/mediagoblin-paster.service
esystemctl daemon-reload
systemctl enable mediagoblin-celeryd
systemctl enable mediagoblin-paster
esystemctl daemon-reload
systemctl start mediagoblin-celeryd
systemctl start mediagoblin-paster
MEDIAGOBLIN_ONION_HOSTNAME=$(add_onion_service mediagoblin 80 ${MEDIAGOBLIN_ONION_PORT}) MEDIAGOBLIN_ONION_HOSTNAME=$(add_onion_service mediagoblin 80 ${MEDIAGOBLIN_ONION_PORT})
if ! grep -q "Mediagoblin onion domain" $COMPLETION_FILE; then if ! grep -q "Mediagoblin onion domain" $COMPLETION_FILE; then