forked from dannyti/seedbox-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathcreateSonarrUserInstall
executable file
·54 lines (43 loc) · 1.94 KB
/
createSonarrUserInstall
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
46
47
48
49
50
51
52
53
54
#!/bin/bash
# Hellish Tech
# No commercial usage without authorization
exec 1> >(logger -s -t $(basename $0)) 2>&1
while [[ $# -gt 1 ]]
do
key="$1"
case $key in
-u|--username)
USERNAME="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
SYSTEMHOSTNAME=`cat /etc/seedbox-from-scratch/hostname.info`
WEBSERVERPORT=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 8889 -ep 8989)
USERUID=$(id -u ${USERNAME})
USERGID=$(id -g ${USERNAME})
docker pull linuxserver/sonarr
docker run --restart=always -d --name ${USERNAME}_sonarr -e LOCAL_USER_ID=${USERUID} -h ${SYSTEMHOSTNAME} -v /home/${USERNAME}/downloads:/downloads -v /home/${USERNAME}/media/TVShows:/tv -v /home/${USERNAME}/sonarr/config:/config -e PGID=${USERGID} -e PUID=${USERUID} -p ${WEBSERVERPORT}:8989 -v /etc/localtime:/etc/localtime:ro linuxserver/sonarr
sleep 5
CHECKIFRUNNING=$(/etc/seedbox-from-scratch/sfsRunningUserDockerInfo -u ${USERNAME} -d sonarr | tr -cd '[[:alnum:]]._-' )
if [[ (${CHECKIFRUNNING} == "STOPPED") || (${CHECKIFRUNNING} == "RUNNING") ]]; then
if [ ! -d "/home/${USERNAME}/sonarr" ]; then
mkdir /home/${USERNAME}/sonarr
mkdir /home/${USERNAME}/sonarr/config
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/sonarr/ -R
fi
echo "SERVICE: sonarr" > /home/${USERNAME}/private/sonarr.serviceinfo
echo "USERNAME: $USERNAME" >> /home/${USERNAME}/private/sonarr.serviceinfo
echo "ACCESSURL: http://$SYSTEMHOSTNAME:$WEBSERVERPORT" >> /home/${USERNAME}/private/sonarr.serviceinfo
echo "WEBSERVERPORT: $WEBSERVERPORT" >> /home/${USERNAME}/private/sonarr.serviceinfo
echo "Please log in and create a username and password, admins are not responsible for user failure to secure the system." >> /home/${USERNAME}/private/sonarr.serviceinfo
chown www-data:www-data /home/${USERNAME}/private/*.serviceinfo
fi
if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 $1
fi