tpotce/installer/bin/update-images.sh

79 lines
1.8 KiB
Bash
Raw Normal View History

2016-02-08 11:21:03 +00:00
#!/bin/bash
2017-03-13 16:10:37 +00:00
##########################################################
# T-Pot #
# Only start the containers found in /etc/systemd/system #
# #
# v17.06 by mo, DTAG, 2017-03-13 #
##########################################################
2016-02-08 11:21:03 +00:00
# Make sure not to interrupt a check
while true
do
if ! [ -a /var/run/check.lock ];
then break
fi
sleep 0.1
if [ "$myCOUNT" = "1" ];
then
echo -n "Waiting for services "
else echo -n .
fi
if [ "$myCOUNT" = "6000" ];
then
echo
echo "Overriding check.lock"
rm /var/run/check.lock
break
fi
myCOUNT=$[$myCOUNT +1]
done
# We do not want to get interrupted by a check
touch /var/run/check.lock
2016-05-30 14:51:32 +00:00
# Stop T-Pot services and disable all T-Pot services
2016-03-10 17:40:28 +00:00
echo "### Stopping T-Pot services and cleaning up."
2017-03-13 21:58:48 +00:00
for i in $(cat /data/all_images.conf);
2016-02-08 14:57:27 +00:00
do
2016-05-12 17:26:06 +00:00
systemctl stop $i
2016-03-10 17:40:28 +00:00
sleep 2
2016-05-28 22:03:46 +00:00
systemctl disable $i;
2017-03-13 16:10:37 +00:00
rm /etc/systemd/system/$i.service
2016-02-08 14:57:27 +00:00
done
2017-03-13 16:10:37 +00:00
# Restarting docker services and optionally clear local repository
echo "### Stopping docker services ..."
2016-05-12 17:26:06 +00:00
systemctl stop docker
2017-03-13 16:10:37 +00:00
sleep 1
# If option "hard" clear the whole repository
if [ "$1" = "hard" ];
then
echo "### Clearing local docker repository."
rm -rf /var/lib/docker
sleep 1
fi
echo "### Starting docker services ..."
2016-05-12 17:26:06 +00:00
systemctl start docker
2017-03-13 16:10:37 +00:00
sleep 1
2016-05-30 14:51:32 +00:00
# Enable only T-Pot upstart scripts from images.conf and pull the images
2017-03-13 21:58:48 +00:00
for i in $(cat /data/imgcfg/images.conf);
2016-03-09 13:05:06 +00:00
do
2017-03-13 16:10:37 +00:00
echo
echo "### Now pulling "$i
2017-03-13 00:38:43 +00:00
docker pull dtagdevsec/$i:1706;
2017-03-13 16:10:37 +00:00
cp /data/systemd/$i.service /etc/systemd/system/
2016-05-28 22:03:46 +00:00
systemctl enable $i;
2016-02-08 11:21:03 +00:00
done
2016-02-08 14:57:27 +00:00
# Announce reboot
2017-03-13 16:10:37 +00:00
echo
echo "### Rebooting."
2016-03-10 17:40:28 +00:00
# Allow checks to resume
rm /var/run/check.lock
# Reboot
reboot