|
@@ -49,89 +49,47 @@ icecast_variables=(MY_USERNAME
|
49
|
49
|
DEFAULT_LANGUAGE)
|
50
|
50
|
|
51
|
51
|
function icecast_update_daemon {
|
52
|
|
- echo '#! /bin/sh' > /etc/init.d/icecast2
|
53
|
|
- echo '#' >> /etc/init.d/icecast2
|
54
|
|
- echo '# icecast2' >> /etc/init.d/icecast2
|
55
|
|
- echo '#' >> /etc/init.d/icecast2
|
56
|
|
- echo '# Written by Miquel van Smoorenburg <miquels@cistron.nl>.' >> /etc/init.d/icecast2
|
57
|
|
- echo '# Modified for Debian' >> /etc/init.d/icecast2
|
58
|
|
- echo '# by Ian Murdock <imurdock@gnu.ai.mit.edu>.' >> /etc/init.d/icecast2
|
59
|
|
- echo '#' >> /etc/init.d/icecast2
|
60
|
|
- echo '# Further modified by Keegan Quinn <ice@thebasement.org>' >> /etc/init.d/icecast2
|
61
|
|
- echo '# for use with Icecast 2' >> /etc/init.d/icecast2
|
62
|
|
- echo '#' >> /etc/init.d/icecast2
|
63
|
|
- echo '' >> /etc/init.d/icecast2
|
64
|
|
- echo 'PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin' >> /etc/init.d/icecast2
|
65
|
|
- echo 'DAEMON=/usr/bin/icecast2' >> /etc/init.d/icecast2
|
66
|
|
- echo 'NAME=icecast2' >> /etc/init.d/icecast2
|
67
|
|
- echo 'DESC=icecast2' >> /etc/init.d/icecast2
|
68
|
|
- echo 'ICES=/usr/bin/ices2' >> /etc/init.d/icecast2
|
69
|
|
- echo 'ICES_CONFIGFILE=/etc/ices2/ices-playlist.xml' >> /etc/init.d/icecast2
|
70
|
|
- echo '' >> /etc/init.d/icecast2
|
71
|
|
- echo 'test -x $DAEMON || exit 0' >> /etc/init.d/icecast2
|
72
|
|
- echo '' >> /etc/init.d/icecast2
|
73
|
|
- echo '# Defaults' >> /etc/init.d/icecast2
|
74
|
|
- echo 'CONFIGFILE="/etc/icecast2/icecast.xml"' >> /etc/init.d/icecast2
|
75
|
|
- echo 'CONFIGDEFAULTFILE="/etc/default/icecast2"' >> /etc/init.d/icecast2
|
76
|
|
- echo 'USERID=icecast2' >> /etc/init.d/icecast2
|
77
|
|
- echo 'GROUPID=icecast' >> /etc/init.d/icecast2
|
78
|
|
- echo 'ENABLE="false"' >> /etc/init.d/icecast2
|
79
|
|
- echo '' >> /etc/init.d/icecast2
|
80
|
|
- echo '# Reads config file (will override defaults above)' >> /etc/init.d/icecast2
|
81
|
|
- echo '[ -r "$CONFIGDEFAULTFILE" ] && . $CONFIGDEFAULTFILE' >> /etc/init.d/icecast2
|
82
|
|
- echo '' >> /etc/init.d/icecast2
|
83
|
|
- echo 'if [ "$ENABLE" != "true" ]; then' >> /etc/init.d/icecast2
|
84
|
|
- echo ' echo "$NAME daemon disabled - read $CONFIGDEFAULTFILE."' >> /etc/init.d/icecast2
|
85
|
|
- echo ' exit 0' >> /etc/init.d/icecast2
|
86
|
|
- echo 'fi' >> /etc/init.d/icecast2
|
87
|
|
- echo '' >> /etc/init.d/icecast2
|
88
|
|
- echo 'set -e' >> /etc/init.d/icecast2
|
89
|
|
- echo '' >> /etc/init.d/icecast2
|
90
|
|
- echo 'case "$1" in' >> /etc/init.d/icecast2
|
91
|
|
- echo ' start)' >> /etc/init.d/icecast2
|
92
|
|
- echo ' echo -n "Starting $DESC: "' >> /etc/init.d/icecast2
|
93
|
|
- echo ' start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \' >> /etc/init.d/icecast2
|
94
|
|
- echo ' --exec $DAEMON -- -b -c $CONFIGFILE' >> /etc/init.d/icecast2
|
95
|
|
- echo ' sleep 3' >> /etc/init.d/icecast2
|
96
|
|
- echo ' start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE' >> /etc/init.d/icecast2
|
97
|
|
- echo ' echo "$NAME."' >> /etc/init.d/icecast2
|
98
|
|
- echo ' ;;' >> /etc/init.d/icecast2
|
99
|
|
- echo ' stop)' >> /etc/init.d/icecast2
|
100
|
|
- echo ' echo -n "Stopping $DESC: "' >> /etc/init.d/icecast2
|
101
|
|
- echo ' start-stop-daemon --stop --oknodo --quiet --exec $ICES' >> /etc/init.d/icecast2
|
102
|
|
- echo '' >> /etc/init.d/icecast2
|
103
|
|
- echo ' start-stop-daemon --stop --oknodo --quiet --exec $DAEMON' >> /etc/init.d/icecast2
|
104
|
|
- echo ' echo "$NAME."' >> /etc/init.d/icecast2
|
105
|
|
- echo ' ;;' >> /etc/init.d/icecast2
|
106
|
|
- echo ' reload|force-reload)' >> /etc/init.d/icecast2
|
107
|
|
- echo ' echo "Reloading $DESC configuration files."' >> /etc/init.d/icecast2
|
108
|
|
- echo ' start-stop-daemon --stop --oknodo --quiet --exec $ICES' >> /etc/init.d/icecast2
|
109
|
|
- echo ' start-stop-daemon --stop --signal 1 --quiet --exec $DAEMON' >> /etc/init.d/icecast2
|
110
|
|
- echo ' sleep 3' >> /etc/init.d/icecast2
|
111
|
|
- echo ' start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE' >> /etc/init.d/icecast2
|
112
|
|
- echo ' ;;' >> /etc/init.d/icecast2
|
113
|
|
- echo ' restart)' >> /etc/init.d/icecast2
|
114
|
|
- echo ' echo -n "Restarting $DESC: "' >> /etc/init.d/icecast2
|
115
|
|
- echo ' start-stop-daemon --stop --oknodo --quiet --exec $ICES' >> /etc/init.d/icecast2
|
116
|
|
- echo '' >> /etc/init.d/icecast2
|
117
|
|
- echo ' start-stop-daemon --stop --oknodo --quiet --exec $DAEMON' >> /etc/init.d/icecast2
|
118
|
|
- echo ' sleep 3' >> /etc/init.d/icecast2
|
119
|
|
- echo ' start-stop-daemon --start --quiet --chuid $USERID:$GROUPID \' >> /etc/init.d/icecast2
|
120
|
|
- echo ' --exec $DAEMON -- -b -c $CONFIGFILE' >> /etc/init.d/icecast2
|
121
|
|
- echo ' sleep 3' >> /etc/init.d/icecast2
|
122
|
|
- echo ' start-stop-daemon --start --quiet --exec $ICES $ICES_CONFIGFILE' >> /etc/init.d/icecast2
|
123
|
|
- echo ' echo "$NAME."' >> /etc/init.d/icecast2
|
124
|
|
- echo ' ;;' >> /etc/init.d/icecast2
|
125
|
|
- echo ' *)' >> /etc/init.d/icecast2
|
126
|
|
- echo ' echo "Usage: $0 {start|stop|restart|reload|force-reload}" >&2' >> /etc/init.d/icecast2
|
127
|
|
- echo ' exit 1' >> /etc/init.d/icecast2
|
128
|
|
- echo ' ;;' >> /etc/init.d/icecast2
|
129
|
|
- echo 'esac' >> /etc/init.d/icecast2
|
130
|
|
- echo '' >> /etc/init.d/icecast2
|
131
|
|
- echo 'exit 0' >> /etc/init.d/icecast2
|
|
52
|
+ systemctl stop icecast2
|
|
53
|
+ if [ -f /etc/init.d/icecast2 ]; then
|
|
54
|
+ rm /etc/init.d/icecast2
|
|
55
|
+ fi
|
|
56
|
+
|
|
57
|
+ echo '[Unit]' > /etc/systemd/system/icecast2.service
|
|
58
|
+ echo 'Description=Icecast' >> /etc/systemd/system/icecast2.service
|
|
59
|
+ echo 'After=network.target' >> /etc/systemd/system/icecast2.service
|
|
60
|
+ echo 'After=tor.service' >> /etc/systemd/system/icecast2.service
|
|
61
|
+ echo '' >> /etc/systemd/system/icecast2.service
|
|
62
|
+ echo '[Service]' >> /etc/systemd/system/icecast2.service
|
|
63
|
+ echo 'User=icecast2' >> /etc/systemd/system/icecast2.service
|
|
64
|
+ echo 'Group=icecast' >> /etc/systemd/system/icecast2.service
|
|
65
|
+ echo "ExecStart=/usr/bin/icecast2 -c /etc/icecast2/icecast.xml" >> /etc/systemd/system/icecast2.service
|
|
66
|
+ echo 'Restart=on-failure' >> /etc/systemd/system/icecast2.service
|
|
67
|
+ echo 'RestartSec=10' >> /etc/systemd/system/icecast2.service
|
|
68
|
+ echo '' >> /etc/systemd/system/icecast2.service
|
|
69
|
+ echo '[Install]' >> /etc/systemd/system/icecast2.service
|
|
70
|
+ echo 'WantedBy=multi-user.target' >> /etc/systemd/system/icecast2.service
|
|
71
|
+
|
|
72
|
+ echo '[Unit]' > /etc/systemd/system/ices2.service
|
|
73
|
+ echo 'Description=Icecast' >> /etc/systemd/system/ices2.service
|
|
74
|
+ echo 'After=network.target' >> /etc/systemd/system/ices2.service
|
|
75
|
+ echo 'After=tor.service' >> /etc/systemd/system/ices2.service
|
|
76
|
+ echo 'After=icecast2.service' >> /etc/systemd/system/ices2.service
|
|
77
|
+ echo '' >> /etc/systemd/system/ices2.service
|
|
78
|
+ echo '[Service]' >> /etc/systemd/system/ices2.service
|
|
79
|
+ echo 'User=icecast2' >> /etc/systemd/system/ices2.service
|
|
80
|
+ echo 'Group=icecast' >> /etc/systemd/system/ices2.service
|
|
81
|
+ echo "ExecStart=/usr/bin/ices2 /etc/ices2/ices-playlist.xml" >> /etc/systemd/system/ices2.service
|
|
82
|
+ echo 'Restart=on-failure' >> /etc/systemd/system/ices2.service
|
|
83
|
+ echo 'RestartSec=10' >> /etc/systemd/system/ices2.service
|
|
84
|
+ echo '' >> /etc/systemd/system/ices2.service
|
|
85
|
+ echo '[Install]' >> /etc/systemd/system/ices2.service
|
|
86
|
+ echo 'WantedBy=multi-user.target' >> /etc/systemd/system/ices2.service
|
132
|
87
|
|
133
|
88
|
systemctl daemon-reload
|
|
89
|
+ systemctl enable icecast2
|
|
90
|
+ systemctl enable ices2
|
134
|
91
|
systemctl restart icecast2
|
|
92
|
+ systemctl restart ices2
|
135
|
93
|
}
|
136
|
94
|
|
137
|
95
|
function change_password_icecast {
|
|
@@ -169,7 +127,7 @@ function icecast_convert_files {
|
169
|
127
|
echo $'Converting any mp4 files to ogv format'
|
170
|
128
|
find . -type f -name '*.mp4' -exec bash -c 'ffmpeg -i "$0" -c:a libvorbis -q:a 4 "${f/%mp4/ogv}' '{}' \;
|
171
|
129
|
|
172
|
|
- chown -R icecast2:icecast2 $ICECAST_DIR
|
|
130
|
+ chown -R icecast2:icecast $ICECAST_DIR
|
173
|
131
|
}
|
174
|
132
|
|
175
|
133
|
function icecast_add_file_to_playlist {
|
|
@@ -192,7 +150,7 @@ function icecast_add_file_to_playlist {
|
192
|
150
|
fi
|
193
|
151
|
done
|
194
|
152
|
|
195
|
|
- chown icecast2:icecast2 $ICECAST_PLAYLIST_FILE
|
|
153
|
+ chown icecast2:icecast $ICECAST_PLAYLIST_FILE
|
196
|
154
|
systemctl restart icecast2
|
197
|
155
|
}
|
198
|
156
|
|
|
@@ -426,7 +384,7 @@ function restore_local_icecast {
|
426
|
384
|
fi
|
427
|
385
|
cp $ICECAST_DIR/.icepasswd /etc/nginx/.icepasswd
|
428
|
386
|
rm $ICECAST_DIR/.icepasswd
|
429
|
|
- chown -R icecast2:icecast2 $ICECAST_DIR
|
|
387
|
+ chown -R icecast2:icecast $ICECAST_DIR
|
430
|
388
|
|
431
|
389
|
systemctl start icecast2
|
432
|
390
|
rm -rf $temp_restore_dir
|
|
@@ -462,7 +420,7 @@ function restore_remote_icecast {
|
462
|
420
|
fi
|
463
|
421
|
cp $ICECAST_DIR/.icepasswd /etc/nginx/.icepasswd
|
464
|
422
|
rm $ICECAST_DIR/.icepasswd
|
465
|
|
- chown -R icecast2:icecast2 $ICECAST_DIR
|
|
423
|
+ chown -R icecast2:icecast $ICECAST_DIR
|
466
|
424
|
|
467
|
425
|
systemctl start icecast2
|
468
|
426
|
rm -rf $temp_restore_dir
|
|
@@ -646,7 +604,7 @@ function install_icecast {
|
646
|
604
|
if [ ! -d $ICECAST_DIR ]; then
|
647
|
605
|
mkdir $ICECAST_DIR
|
648
|
606
|
fi
|
649
|
|
- chown -R icecast2:icecast2 $ICECAST_DIR
|
|
607
|
+ chown -R icecast2:icecast $ICECAST_DIR
|
650
|
608
|
|
651
|
609
|
|
652
|
610
|
# create a password for users
|
|
@@ -663,6 +621,9 @@ function install_icecast {
|
663
|
621
|
${PROJECT_NAME}-pass -u $MY_USERNAME -a icecast -p "$ICECAST_PASSWORD"
|
664
|
622
|
${PROJECT_NAME}-pass -u $MY_USERNAME -a icecastuser -p "$ICECAST_USER_PASSWORD"
|
665
|
623
|
|
|
624
|
+ groupadd icecast
|
|
625
|
+ useradd -c "Icecast system account" -d /etc/icecast2 -m -r -g icecast icecast2
|
|
626
|
+
|
666
|
627
|
icecast_update_daemon
|
667
|
628
|
nginx_ensite icecast
|
668
|
629
|
systemctl restart nginx
|