-
Notifications
You must be signed in to change notification settings - Fork 7
/
DocSeed.sh
executable file
·163 lines (141 loc) · 5.03 KB
/
DocSeed.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/bin/bash
# Seedbox manager
#
# author : zerpex ( [email protected] )
# Last updated : 2018 01 02
# Version 1.6
#
# Github : https://github.com/zerpex/seedbox_docker
# Define path
PWD=$(pwd)
SCRPATH=$PWD/files/scripts
# Check if system is debian based
if [ ! -f /etc/debian_version ]; then
echo -e "${CRED}This script has been writen for Debian-based distros."
exit 1
fi
# Check if root or sudo:
if [[ $(id -u) -ne 0 ]] ; then
echo 'Please run me as root or with sudo'
exit 1
fi
# Installation pre-requiresites
echo " "
echo -e "${CGREEN}Installing pre-requiresites:$CEND"
echo " "
apt-get update
apt-get -y upgrade
apt-get -y install dialog sudo apt-transport-https ca-certificates curl dnsutils software-properties-common
# Variables includes
source config.local
# Installation menu begin
if [ -z $DISPLAY ]
then
DIALOG=dialog
else
DIALOG=Xdialog
fi
if [ ! -z $(docker --version | grep "not found") ]; then
# OK to check and install docker ?
$DIALOG --title " IMPORTANT " --clear \
--yesno "This script require docker and docker-compose, it will install it automatically.\n
Do you agree ?" 15 75
case $? in
0)# Install docker
source $SCRPATH/ins_docker.sh
# Install docker-compose
source $SCRPATH/ins_docker-compose.sh
;;
1)# Can't do anything without docker
echo "KTHXBYE."
exit 0
;;
esac
fi
# Define the root path
D_PATH=($DIALOG --title " Root path " --clear \
--inputbox "Please set the root path of your installation
( default to /home/seebox ) :" 16 75 "/home/seebox")
DEFAULT_PATH=$("${D_PATH[@]}" 2>&1 >/dev/tty)
# Define the incoming path
I_PATH=($DIALOG --title " Incoming path " --clear \
--inputbox "Please set the path of your incoming folder
( default to $DEFAULT_PATH/incoming ) :" 16 75 "$DEFAULT_PATH/incoming")
INC_PATH=$("${I_PATH[@]}" 2>&1 >/dev/tty)
# Define the media path
M_PATH=($DIALOG --title " Media path " --clear \
--inputbox "Please set the path of your media folder
( default to $DEFAULT_PATH/media ) :" 16 75 "$DEFAULT_PATH/media")
MEDIA_PATH=$("${M_PATH[@]}" 2>&1 >/dev/tty)
# Define the containers' configuration path
C_PATH=($DIALOG --title " Configuration path " --clear \
--inputbox "Please set the path where you want to store apps configuration files
( default to $PWD/files/apps ) :" 16 75 "$PWD/files/apps")
CONF_PATH=$("${C_PATH[@]}" 2>&1 >/dev/tty)
# Create all this directories
mkdir -p $DEFAULT_PATH $INC_PATH $MEDIA_PATH $CONF_PATH
IFACE=$WAN
# Down previously created containers before changing configuration
docker-compose down
# Begin generating docker receipe
cat files/includes/head.docker > docker-compose.yml
# Select apps to install
cmd=(dialog --separate-output --checklist "Select options:" 22 85 16)
options=("Traefik" "Proxy and certificates manager (Mandatory)" on
"Nextcloud" "Cloud (recommanded)" on
"Muximux" "Application management console (recommanded)" on
"rTorrent" "Download : Torrents" off
"SABnzdb" "Download : Newsgroups" off
"Emby" "Streaming : Video" off
"Libresonic" "Streaming : Music" off
"Ubooquity" "Streaming : Comics" off
"Radarr" "Automation : Movies" off
"Medusa" "Automation : TV shows" off
"Headphones" "Automation : Music" off
"Mylar" "Automation : Comics" off
"Watchtower" "Tool : Auto-update apps (Heavily recommanded)" on
"Portainer" "Tool : Containers management through browser (recomanded)" on
"Syncthing" "Tool : Devices synchronisation" on)
choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
clear
# Install selected apps
for choice in $choices
do
source $SCRPATH/app_$choice.sh
done
cat files/includes/foot.docker >> docker-compose.yml
# Set global variables
sed -i "s@1069@$SUID@g" docker-compose.yml
sed -i "s@1069@$SGID@g" docker-compose.yml
sed -i "s@CONF@$CONF_PATH@g" docker-compose.yml
# Set permissions
chown -R $SUID:$SGID $DEFAULT_PATH
chown -R $SUID:$SGID $INC_PATH
chown -R $SUID:$SGID $MEDIA_PATH
# Update Muximux conf
mkdir -p $CONF_PATH/muximux/conf/www/muximux
cp files/includes/muximux.conf $CONF_PATH/muximux/conf/www/muximux/settings.ini.php
chown -R $SUID:$SGID $CONF_PATH/muximux/conf/www/muximux/settings.ini.php
# Generate and start all needeed containers
docker network create traefik_proxy
docker-compose up -d
sleep 10
# Writing a beautifull resume
for APP in "${INSTALLED[@]}"
do
CNAME=_CNAME
SDOM=_SDOM
CONTNAME=$(eval "echo \$$APP$CNAME")
FDOM=$(eval "echo \$$APP$SDOM").$DOMAIN
FNAME=`echo $CONTNAME | awk -F_ '{print $2}'`
STATE=`docker inspect -f {{.State.Running}} $CONTNAME`
if [ "$STATE" == "true" ]
then
echo -e "=> [ ${CGREEN}OK$CEND ] $FNAME is now installed and running at ${CYELLOW}https://$FDOM$CEND"
else
echo -e "!! [ ${CRED}KO$CEND ] $FNAME is not installed, but not running. Please check logs with "docker logs $CONTNAME" !"
fi
done
echo " "
echo -e "If you installed Muximux, you can access all your apps directly through : ${CYELLOW}https://$Mx_SDOM.$DOMAIN$CEND"
echo " "