-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcouchpotato.sh
45 lines (36 loc) · 918 Bytes
/
couchpotato.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
set -e
#
# Display settings on standard out.
#
USER="couchpotato"
echo "CouchPotato settings"
echo "===================="
echo
echo " User: ${USER}"
echo " UID: ${CP_UID:=666}"
echo " GID: ${CP_GID:=666}"
echo
echo " Config: ${CONFIG:=/datadir/config.ini}"
echo
#
# Change UID / GID of CouchPotato user.
#
printf "Updating UID / GID... "
[[ $(id -u ${USER}) == ${CP_UID} ]] || usermod -o -u ${CP_UID} ${USER}
[[ $(id -g ${USER}) == ${CP_GID} ]] || groupmod -o -g ${CP_GID} ${USER}
echo "[DONE]"
#
# Set directory permissions.
#
printf "Set permissions... "
touch ${CONFIG}
chown -R ${USER}: /couchpotato
chown ${USER}: /datadir /media $(dirname ${CONFIG})
echo "[DONE]"
#
# Finally, start CouchPotato.
#
CONFIG=${CONFIG:-/datadir/config.ini}
echo "Starting CouchPotato..."
exec su -pc "./CouchPotato.py --data_dir=$(dirname ${CONFIG}) --config_file=${CONFIG}" ${USER}