Skip to content

Commit 3b143ff

Browse files
committed
Added function to add custom containers
1 parent 6faa833 commit 3b143ff

File tree

1 file changed

+40
-26
lines changed

1 file changed

+40
-26
lines changed

menu.sh

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -74,40 +74,42 @@ function command_exists() {
7474

7575
#function copies the template yml file to the local service folder and appends to the docker-compose.yml file
7676
function yml_builder() {
77+
7778
service="services/$1/service.yml"
7879

7980
[ -d ./services/ ] || mkdir ./services/
8081

81-
if [ -d ./services/$1 ]; then
82-
#directory already exists prompt user to overwrite
83-
sevice_overwrite=$(whiptail --radiolist --title "Overwrite Option" --notags \
84-
"$1 service directory has been detected, use [SPACEBAR] to select you overwrite option" 20 78 12 \
85-
"none" "Do not overwrite" "ON" \
86-
"env" "Preserve Environment and Config files" "OFF" \
87-
"full" "Pull full service from template" "OFF" \
88-
3>&1 1>&2 2>&3)
89-
90-
case $sevice_overwrite in
82+
if [ -d ./services/$1 ]; then
83+
#directory already exists prompt user to overwrite
84+
sevice_overwrite=$(whiptail --radiolist --title "Overwrite Option" --notags \
85+
"$1 service directory has been detected, use [SPACEBAR] to select you overwrite option" 20 78 12 \
86+
"none" "Do not overwrite" "ON" \
87+
"env" "Preserve Environment and Config files" "OFF" \
88+
"full" "Pull full service from template" "OFF" \
89+
3>&1 1>&2 2>&3)
90+
91+
case $sevice_overwrite in
92+
93+
"full")
94+
echo "...pulled full $1 from template"
95+
rsync -a -q .templates/$1/ services/$1/ --exclude 'build.sh'
96+
;;
97+
"env")
98+
echo "...pulled $1 excluding env file"
99+
rsync -a -q .templates/$1/ services/$1/ --exclude 'build.sh' --exclude '$1.env' --exclude '*.conf'
100+
;;
101+
"none")
102+
echo "...$1 service not overwritten"
103+
;;
104+
105+
esac
91106

92-
"full")
107+
else
108+
mkdir ./services/$1
93109
echo "...pulled full $1 from template"
94110
rsync -a -q .templates/$1/ services/$1/ --exclude 'build.sh'
95-
;;
96-
"env")
97-
echo "...pulled $1 excluding env file"
98-
rsync -a -q .templates/$1/ services/$1/ --exclude 'build.sh' --exclude '$1.env' --exclude '*.conf'
99-
;;
100-
"none")
101-
echo "...$1 service not overwritten"
102-
;;
103-
104-
esac
111+
fi
105112

106-
else
107-
mkdir ./services/$1
108-
echo "...pulled full $1 from template"
109-
rsync -a -q .templates/$1/ services/$1/ --exclude 'build.sh'
110-
fi
111113

112114
#if an env file exists check for timezone
113115
[ -f "./services/$1/$1.env" ] && timezones ./services/$1/$1.env
@@ -245,9 +247,21 @@ case $mainmenu_selection in
245247
echo "$container" >>./services/selection.txt
246248
done
247249

250+
# add custom containers
251+
if [ -f ./services/custom.txt ]; then
252+
if (whiptail --title "Custom Container detected" --yesno "custom.txt has been detected do you want to add these containers to the stack?" 20 78); then
253+
mapfile -t containers <<<$(cat ./services/custom.txt)
254+
for container in "${containers[@]}"; do
255+
echo "Adding $container container"
256+
yml_builder "$container"
257+
done
258+
fi
259+
fi
260+
248261
echo "docker-compose successfully created"
249262
echo "run 'docker-compose up -d' to start the stack"
250263
else
264+
251265
echo "Build cancelled"
252266

253267
fi

0 commit comments

Comments
 (0)