74 lines
1.8 KiB
Bash
Executable File
74 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
install_prerequisite_software ()
|
|
{
|
|
if [ -n "$(which git)" ] & [ -n "$(which podman)" ] & [ -n "$(which podman-compose)" ]
|
|
then
|
|
echo "Git, podman and podman-compose are already installed."
|
|
elif [ -n "$(which apk)" ]
|
|
then
|
|
apk update
|
|
apk add git podman podman-compose
|
|
elif [ -n "$(which apt-get)" ]
|
|
then
|
|
apt-get update
|
|
apt-get install git podman podman-compose -y
|
|
elif [ -n "$(which dnf)" ]
|
|
then
|
|
dnf install git podman podman-compose
|
|
elif [ -n "$(which yum)" ]
|
|
then
|
|
yum install git podman podman-compose
|
|
elif [ -n "$(which pacman)" ]
|
|
then
|
|
pacman -S git podman podman-compose
|
|
else
|
|
echo "Could not install Git: could not identify package manager."
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
clone_repository ()
|
|
{
|
|
cd ${LIB_DIR:-/lib}
|
|
git clone https://git.joeac.net/joeac/joeac.net.git
|
|
cd joeac.net
|
|
chmod +x uninstall.sh update_and_restart.sh restart.sh
|
|
}
|
|
|
|
add_cron_services ()
|
|
{
|
|
echo <<- EOF > ${CRONTABS_DIR:-/etc/cron.d}/joeacnet
|
|
@reboot ${LIB_DIR:-/lib}/joeac.net/restart.sh
|
|
10 * * * * ${LIB_DIR:-/lib}/joeac.net/update_and_restart.sh
|
|
EOF
|
|
}
|
|
|
|
collect_env_vars ()
|
|
{
|
|
if ! [ -f /resticprofile.env ]
|
|
then
|
|
echo "Please provide resticprofile secrets in /resticprofile.env."
|
|
exit 1
|
|
fi
|
|
cp /resticprofile.env "${LIB_DIR:-/lib}/joeac.net/resticprofile/.env"
|
|
|
|
if ! [ -f /symfony.env ]
|
|
then
|
|
echo "Please provide symfony secrets in /symfony.env."
|
|
exit 1
|
|
fi
|
|
cp /symfony.env "${LIB_DIR:-/lib}/joeac.net/symfony/.env"
|
|
}
|
|
|
|
# Run me:
|
|
# curl https://git.joeac.net/joeac/joeac.net/raw/branch/main/install.sh | sudo -E sh
|
|
|
|
set -eux
|
|
install_prerequisite_software
|
|
clone_repository
|
|
add_cron_services
|
|
set -e +ux
|
|
collect_env_vars
|
|
./restart.sh
|