forked from dannyti/seedbox-from-scratch
-
Notifications
You must be signed in to change notification settings - Fork 4
/
createFileZillaUserInstall
executable file
·54 lines (44 loc) · 2.01 KB
/
createFileZillaUserInstall
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`
WEBSERVERPORT1=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 5801 -ep 5899)
WEBSERVERPORT2=$(/etc/seedbox-from-scratch/sfsgetAvailablePort -sp 5901 -ep 5999)
USERUID=$(id -u ${USERNAME})
USERGID=$(id -g ${USERNAME})
RANDOMPASS=$(tr -d -c "a-zA-Z0-9" < /dev/urandom | head -c 8)
docker pull jlesage/filezilla
docker run --restart=always -d --name ${USERNAME}_filezilla -e USER_ID=${USERUID} -e GROUP_ID=${USERGID} -h ${SYSTEMHOSTNAME} -e VNC_PASSWORD=${RANDOMPASS} -e SECURE_CONNECTION=1 -v /home/${USERNAME}/downloads:/storage:rw -v /home/${USERNAME}/filezilla/config:/config:rw -e PGID=${USERGID} -e PUID=${USERUID} -p ${WEBSERVERPORT1}:5800 -p ${WEBSERVERPORT2}:5900 -v /etc/localtime:/etc/localtime:ro jlesage/filezilla
sleep 5
CHECKIFRUNNING=$(/etc/seedbox-from-scratch/sfsRunningUserDockerInfo -u ${USERNAME} -d filezilla | tr -cd '[[:alnum:]]._-' )
if [[ (${CHECKIFRUNNING} == "STOPPED") || (${CHECKIFRUNNING} == "RUNNING") ]]; then
if [ ! -d "/home/${USERNAME}/filezilla" ]; then
mkdir /home/${USERNAME}/filezilla
mkdir /home/${USERNAME}/filezilla/config
chown ${USERNAME}:${USERNAME} /home/${USERNAME}/filezilla/ -R
fi
echo "SERVICE: filezilla" > /home/${USERNAME}/private/filezilla.serviceinfo
echo "PASSWORD: $RANDOMPASS" >> /home/${USERNAME}/private/filezilla.serviceinfo
echo "ACCESSURL: http://$SYSTEMHOSTNAME:$WEBSERVERPORT1" >> /home/${USERNAME}/private/filezilla.serviceinfo
echo "VNCPORT: $WEBSERVERPORT2" >> /home/${USERNAME}/private/filezilla.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