fix permissions in vm build script, add systemd service files, support debian/systemd in vm build script
This commit is contained in:
parent
cf862fc7d6
commit
608745e396
6 changed files with 143 additions and 11 deletions
19
etc/systemd/pandora-cron.service
Normal file
19
etc/systemd/pandora-cron.service
Normal file
|
@ -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
|
21
etc/systemd/pandora-encoding.service
Normal file
21
etc/systemd/pandora-encoding.service
Normal file
|
@ -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
|
21
etc/systemd/pandora-tasks.service
Normal file
21
etc/systemd/pandora-tasks.service
Normal file
|
@ -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
|
24
etc/systemd/pandora.service
Normal file
24
etc/systemd/pandora.service
Normal file
|
@ -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
|
1
etc/tmpfiles.d/pandora.conf
Normal file
1
etc/tmpfiles.d/pandora.conf
Normal file
|
@ -0,0 +1 @@
|
||||||
|
d /run/pandora 0755 pandora pandora -
|
|
@ -1,12 +1,31 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
LXC=`grep -q lxc /proc/1/environ && echo 'yes' || echo 'no'`
|
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
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
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 \
|
apt-get install -y \
|
||||||
update-manager-core \
|
update-manager-core \
|
||||||
software-properties-common
|
software-properties-common \
|
||||||
[[ `lsb_release -sr` == "12.04" ]] && apt-get install -y python-software-properties
|
$EXTRA
|
||||||
|
|
||||||
add-apt-repository -y ppa:j/pandora
|
add-apt-repository -y ppa:j/pandora
|
||||||
|
fi
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
if [ "$LXC" == "no" ]; then
|
if [ "$LXC" == "no" ]; then
|
||||||
|
@ -15,7 +34,7 @@ apt-get install -y \
|
||||||
ntp
|
ntp
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ `lsb_release -sr` == "12.04" ]]; then
|
if [ "$UBUNTU_VERSION" == "12.04" ]; then
|
||||||
LIBAVCODEC_EXTRA=libavcodec-extra-53
|
LIBAVCODEC_EXTRA=libavcodec-extra-53
|
||||||
else
|
else
|
||||||
LIBAVCODEC_EXTRA=libavcodec-extra
|
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/ffmpeg https://firefogg.org/bin/ffmpeg.linux
|
||||||
wget -O /home/pandora/.ox/bin/ffmpeg2theora https://firefogg.org/bin/ffmpeg2theora.linux
|
wget -O /home/pandora/.ox/bin/ffmpeg2theora https://firefogg.org/bin/ffmpeg2theora.linux
|
||||||
chmod +x /home/pandora/.ox/bin/*
|
chmod +x /home/pandora/.ox/bin/*
|
||||||
|
chown -R pandora.pandora /home/pandora/.ox
|
||||||
|
|
||||||
|
|
||||||
sudo -u postgres createuser -S -D -R pandora
|
sudo -u postgres createuser -S -D -R pandora
|
||||||
|
@ -119,10 +139,21 @@ chown -R pandora:pandora /srv/pandora
|
||||||
$MANAGE update_static
|
$MANAGE update_static
|
||||||
$MANAGE collectstatic -l --noinput
|
$MANAGE collectstatic -l --noinput
|
||||||
|
|
||||||
|
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/
|
cp /srv/pandora/etc/init/* /etc/init/
|
||||||
if [ "$LXC" == "yes" ]; then
|
if [ "$LXC" == "yes" ]; then
|
||||||
sed -i s/127.0.0.1/0.0.0.0/g /etc/init/pandora.conf
|
sed -i s/127.0.0.1/0.0.0.0/g /etc/init/pandora.conf
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
/srv/pandora/ctl start
|
/srv/pandora/ctl start
|
||||||
|
|
||||||
#logrotate
|
#logrotate
|
||||||
|
@ -161,12 +192,26 @@ EOF
|
||||||
chmod +x /usr/local/bin/fixtime
|
chmod +x /usr/local/bin/fixtime
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$ID" == "systemd" ]; then
|
||||||
|
cat > /usr/local/bin/genissue <<EOF
|
||||||
|
#!/bin/bash
|
||||||
|
echo Welcome to pan.do/ra. Connect via one of these URLs:
|
||||||
|
echo
|
||||||
|
for ip in \$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print \$1 }'); do
|
||||||
|
echo " http://\$ip/"
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
EOF
|
||||||
|
chmod +x /usr/local/bin/genissue
|
||||||
|
/usr/local/bin/genissue > /etc/issue
|
||||||
|
|
||||||
|
else
|
||||||
cat > /usr/local/bin/genissue <<EOF
|
cat > /usr/local/bin/genissue <<EOF
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
HOST=\$(rgrep .local /var/log/syslog | grep "Host name is" | tail -n 1 | awk '{print \$12}' | sed 's/\.$//')
|
HOST=\$(rgrep .local /var/log/syslog | grep "Host name is" | tail -n 1 | awk '{print \$12}' | sed 's/\.$//')
|
||||||
echo Welcome to pan.do/ra. Connect via one of these URLs:
|
echo Welcome to pan.do/ra. Connect via one of these URLs:
|
||||||
echo
|
echo
|
||||||
if [ -n "$HOST" ]; then
|
if [ -n "\$HOST" ]; then
|
||||||
echo " http://\$HOST/"
|
echo " http://\$HOST/"
|
||||||
fi
|
fi
|
||||||
for ip in \$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print \$1 }'); do
|
for ip in \$(ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print \$1 }'); do
|
||||||
|
@ -194,6 +239,7 @@ cat >> /etc/rc.local << EOF
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
chmod +x /etc/rc.local
|
chmod +x /etc/rc.local
|
||||||
|
fi
|
||||||
|
|
||||||
cat > /home/pandora/.vimrc <<EOF
|
cat > /home/pandora/.vimrc <<EOF
|
||||||
set nocompatible
|
set nocompatible
|
||||||
|
|
Loading…
Reference in a new issue