99 lines
3.0 KiB
Bash
Executable File
99 lines
3.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Cleanly kill supervisor when container is stopped
|
|
trap 'kill $(jobs -p)' EXIT
|
|
|
|
function build_modules {
|
|
echo "Building modules..."
|
|
cd /srv/znc/module-source/c
|
|
znc-buildmod *.cpp
|
|
mv *.so /usr/lib/znc/
|
|
}
|
|
|
|
if [ ! -f /srv/znc/configs/znc.conf ]; then
|
|
#echo "Welcome! I need to ask you a few questions to configure this ZNC instance for your liking. First, press enter choose and choose a time zone."
|
|
#read
|
|
|
|
#dpkg-reconfigure tzdata
|
|
|
|
if [ ! -f /znc.tar.gz ]; then
|
|
echo "If you want to load data from and existing znc instance create a tar.gz archive containing only the .znc directory and place it in the root of this container as znc.tar.gz."
|
|
echo "Copy the archive to the container using this command: cat znc.tar.gz | docker exec -i <containerid> bash -c \"/bin/cat > /znc.tar.gz\""
|
|
echo "Press enter when done. Or, to set up a new znc instance, press enter now."
|
|
read
|
|
fi
|
|
|
|
if [ -f /znc.tar.gz ]; then
|
|
su -c "cd /srv ; tar zxvf /znc.tar.gz " znc
|
|
rm /znc.tar.gz
|
|
echo "Extracted znc data"
|
|
if [ ! -d /srv/znc ]; then
|
|
echo "'znc' was not in the archive! Aborted"
|
|
exit 1
|
|
fi
|
|
chown -R znc:znc /srv/znc
|
|
chmod -R 700 /srv/znc
|
|
echo "ZNC settings loaded successfully."
|
|
else
|
|
echo "Configure ZNC to your liking now. Remember to choose NO when asked to launch znc!!"
|
|
su -c "/usr/bin/znc --makeconf --datadir /srv/znc" znc
|
|
echo "ZNC configured successfully."
|
|
fi
|
|
|
|
echo "Enter a username and password to view pisg statistics"
|
|
while [ 1 ]; do
|
|
|
|
echo -n "Username: "
|
|
read ng_username
|
|
|
|
echo -n "Password: "
|
|
read -s ng_password
|
|
echo ""
|
|
|
|
echo -n "Password (again): "
|
|
read -s ng_password_
|
|
echo ""
|
|
|
|
if [ ! "$ng_password" == "$ng_password_" ] || [ -z "$ng_password" ] || [ -z "$ng_username" ] ; then
|
|
echo "Passwords must match and not be blank"
|
|
echo ""
|
|
continue
|
|
fi
|
|
break
|
|
done
|
|
|
|
mkdir -p /srv/znc/caches/tmp /srv/znc/caches/pisg /srv/znc/caches/pisg-web/pub /srv/znc/caches/nginx
|
|
chown znc:znc /srv/znc/caches
|
|
|
|
printf "$ng_username:$(openssl passwd -crypt $ng_password)\n" > /srv/znc/caches/nginx/htpasswd
|
|
|
|
build_modules
|
|
|
|
echo "Now, start a new container with the same volumes using -d."
|
|
|
|
echo -n "Do you want to make any other changes inside this container? (y/N): "
|
|
read domore
|
|
if [ "$domore" == "y" ] ; then
|
|
echo "Type 'exit' when finished."
|
|
exec bash
|
|
fi
|
|
|
|
exit
|
|
fi
|
|
|
|
# we probably want this dir to persist...
|
|
if [ ! -f "/etc/ssh/keys/ssh_host_rsa_key" ]; then
|
|
# Regen keys
|
|
ssh-keygen -A
|
|
|
|
# Move keys to keys dir
|
|
mv /etc/ssh/ssh_host_* /etc/ssh/keys/
|
|
fi
|
|
|
|
mkdir -p /srv/znc/caches/tmp /srv/znc/caches/pisg /srv/znc/caches/pisg-web/pub /srv/znc/caches/nginx
|
|
chown znc:znc /srv/znc/caches
|
|
|
|
build_modules
|
|
|
|
supervisord
|