diff --git a/etc/systemd/pandora-cron.service b/etc/systemd/pandora-cron.service new file mode 100644 index 00000000..b9cac801 --- /dev/null +++ b/etc/systemd/pandora-cron.service @@ -0,0 +1,19 @@ +[Unit] +Description=pandora cron daemon + +[Service] +Type=simple +Restart=always +User=pandora +Group=pandora +PIDFile=/run/pandora/cron.pid +WorkingDirectory=/srv/pandora/pandora +StandardOutput=syslog +StandardError=syslog +ExecStart=/srv/pandora/bin/python /srv/pandora/pandora/manage.py \ + celerybeat -s /run/pandora/celerybeat-schedule \ + --pidfile /run/pandora/cron.pid \ + -l INFO +ExecReload=/bin/kill -HUP $MAINPID +[Install] +WantedBy=multi-user.target diff --git a/etc/systemd/pandora-encoding.service b/etc/systemd/pandora-encoding.service new file mode 100644 index 00000000..3b2cec07 --- /dev/null +++ b/etc/systemd/pandora-encoding.service @@ -0,0 +1,21 @@ +[Unit] +Description=pandora encoding daemon + +[Service] +Type=simple +Restart=always +User=pandora +Group=pandora +PIDFile=/run/pandora/encoding.pid +WorkingDirectory=/srv/pandora/pandora +StandardOutput=syslog +StandardError=syslog +ExecStart=/srv/pandora/bin/python /srv/pandora/pandora/manage.py \ + celeryd \ + -Q encoding -n pandora-encoding \ + --pidfile /run/pandora/encoding.pid \ + -l INFO +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/etc/systemd/pandora-tasks.service b/etc/systemd/pandora-tasks.service new file mode 100644 index 00000000..494b3728 --- /dev/null +++ b/etc/systemd/pandora-tasks.service @@ -0,0 +1,21 @@ +[Unit] +Description=pandora tasks daemon + +[Service] +Type=simple +Restart=always +User=pandora +Group=pandora +PIDFile=/run/pandora/tasks.pid +WorkingDirectory=/srv/pandora/pandora +StandardOutput=syslog +StandardError=syslog +ExecStart=/srv/pandora/bin/python /srv/pandora/pandora/manage.py \ + celeryd \ + -Q default,celery -n pandora-default \ + --pidfile /run/pandora/tasks.pid \ + -l INFO +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/etc/systemd/pandora.service b/etc/systemd/pandora.service new file mode 100644 index 00000000..f9fd2daa --- /dev/null +++ b/etc/systemd/pandora.service @@ -0,0 +1,24 @@ +[Unit] +Description=pandora daemon + +[Service] +Type=simple +Restart=always +User=pandora +Group=pandora +PIDFile=/run/pandora/pandora.pid +WorkingDirectory=/srv/pandora/pandora +StandardOutput=syslog +StandardError=syslog +ExecStartPre=/srv/pandora/pandora/manage.py compile_pyc +ExecStart=/srv/pandora/bin/gunicorn_django \ + -p /run/pandora/pandora.pid \ + --bind 127.0.0.1:2620 \ + --timeout 90 \ + --max-requests 1000 \ + --log-level info \ + --workers 5 +ExecReload=/bin/kill -HUP $MAINPID + +[Install] +WantedBy=multi-user.target diff --git a/etc/tmpfiles.d/pandora.conf b/etc/tmpfiles.d/pandora.conf new file mode 100644 index 00000000..dc2a066a --- /dev/null +++ b/etc/tmpfiles.d/pandora.conf @@ -0,0 +1 @@ +d /run/pandora 0755 pandora pandora - diff --git a/vm/firstboot.sh b/vm/firstboot.sh index d1702da0..db88dd4d 100755 --- a/vm/firstboot.sh +++ b/vm/firstboot.sh @@ -1,12 +1,31 @@ #!/bin/bash LXC=`grep -q lxc /proc/1/environ && echo 'yes' || echo 'no'` - +if [ -e /etc/os-release ]; then + . /etc/os-release +else + ID=unknown +fi +UBUNTU_VERSION="$VERSION_ID" export DEBIAN_FRONTEND=noninteractive -apt-get install -y \ - update-manager-core \ - software-properties-common -[[ `lsb_release -sr` == "12.04" ]] && apt-get install -y python-software-properties -add-apt-repository -y ppa:j/pandora +if [ "$ID" == "debian" ]; then + SYSTEMD="yes" + echo "deb http://ppa.launchpad.net/j/pandora/ubuntu trusty main" > /etc/apt/sources.list.d/j-pandora.list + gpg --keyserver subkeys.pgp.net --recv-keys 01975EF3 + gpg -a --export 01975EF3 | apt-key add - +else + SYSTEMD="no" + if [ "$UBUNTU_VERSION" == "12.04" ]; then + EXTRA=python-software-properties + else + EXTRA="" + fi + apt-get install -y \ + update-manager-core \ + software-properties-common \ + $EXTRA + + add-apt-repository -y ppa:j/pandora +fi apt-get update if [ "$LXC" == "no" ]; then @@ -15,7 +34,7 @@ apt-get install -y \ ntp fi -if [[ `lsb_release -sr` == "12.04" ]]; then +if [ "$UBUNTU_VERSION" == "12.04" ]; then LIBAVCODEC_EXTRA=libavcodec-extra-53 else LIBAVCODEC_EXTRA=libavcodec-extra @@ -63,6 +82,7 @@ mkdir -p /home/pandora/.ox/bin wget -O /home/pandora/.ox/bin/ffmpeg https://firefogg.org/bin/ffmpeg.linux wget -O /home/pandora/.ox/bin/ffmpeg2theora https://firefogg.org/bin/ffmpeg2theora.linux chmod +x /home/pandora/.ox/bin/* +chown -R pandora.pandora /home/pandora/.ox sudo -u postgres createuser -S -D -R pandora @@ -119,9 +139,20 @@ chown -R pandora:pandora /srv/pandora $MANAGE update_static $MANAGE collectstatic -l --noinput -cp /srv/pandora/etc/init/* /etc/init/ -if [ "$LXC" == "yes" ]; then - sed -i s/127.0.0.1/0.0.0.0/g /etc/init/pandora.conf +if [ "$SYSTEMD" == "yes" ]; then + cp /srv/pandora/etc/systemd/*.service /lib/systemd/system/ + cp /srv/pandora/etc/tmpfiles.d/*.conf /usr/lib/tmpfiles.d/ + if [ "$LXC" == "yes" ]; then + sed -i s/127.0.0.1/0.0.0.0/g /lib/systemd/system/pandora.service + fi + for service in pandora pandora-tasks pandora-encoding pandora-cron; do + systemctl enable ${service}.service + done +else + cp /srv/pandora/etc/init/* /etc/init/ + if [ "$LXC" == "yes" ]; then + sed -i s/127.0.0.1/0.0.0.0/g /etc/init/pandora.conf + fi fi /srv/pandora/ctl start @@ -161,12 +192,26 @@ EOF chmod +x /usr/local/bin/fixtime fi +if [ "$ID" == "systemd" ]; then +cat > /usr/local/bin/genissue < /etc/issue + +else cat > /usr/local/bin/genissue <> /etc/rc.local << EOF EOF fi chmod +x /etc/rc.local +fi cat > /home/pandora/.vimrc <