server-origin/install.sh

109 lines
2.2 KiB
Bash
Raw Normal View History

2024-08-08 06:01:49 +05:00
#!/bin/bash
#SECRETS_STORE=/data/secrets/secrets.env
GIT_SSH_DOMAIN=rozenlab.com
GIT_USER=leo
PGUSER=admin
PGDATABASE=postgres
LETSENCRYPT_EMAIL=426742@gmail.com
TRAEFIKLOGLEVEL=DEBUG # / INFO / ERROR
ADMINEMAIL=426742@gmail.com
STARTDIR=server-origin
SSHPORT=2525
if [ "$(id -u)" != "0" ]; then
echo "This script requires superuser rights. Running with sudo..."
exec sudo "$0" "$@"
fi
if [ -z "$1" ]; then
echo "Please provide the DOMAIN_NAME as an argument"
exit 1
fi
#if [ -f $SECRETS_STORE ]; then
# source $SECRETS_STORE
#fi
trap 'echo -e "\033[31mSomething went wrong\033[0m"; exit 1' EXIT
set -e
export DEBIAN_FRONTEND=noninteractive
$DOMAIN=$1
#$SERVER_TYPE=dev
mkdir -p /data
chown usradmin:usradmin /data
chmod 770 /data
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/utils.git
cd /data/utils
#bash init-server.sh
bash init-docker.sh
docker network create proxynet
# SSH config:
#bash ssh-port.sh $SSHPORT
#ssh-keygen -t ed25519 -C "$ADMINEMAIL"
bash cron-list.sh
# create global environment vars:
bash global-env.sh SERVER_DOMAIN $DOMAIN
bash global-env.sh POSTGRES_USER $PGUSER
bash global-env.sh POSTGRES_DB $PGDATABASE
bash global-env.sh TRAEFIK_LOG_LEVEL $TRAEFIKLOGLEVEL
bash global-env.sh ADMIN_EMAIL $ADMINEMAIL
bash global-env.sh SRV_START_DIR $STARTDIR
#bash global-env.sh SERVER_TYPE $SERVER_TYPE
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/backup.git
cd /data/utils
#bash env-gen.sh LE_EMAIL "$LETSENCRYPT_EMAIL"
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/traefik.git
cd traefik
sudo docker compose up -d
cd /data/utils
bash env-gen.sh POSTGRES_PASSWORD
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/postgres.git
cd postgres
sudo docker compose up -d
# pgadmin install:
mkdir -p /data/appdata/pgadmin
chown -R 5050:5050 /data/appdata/pgadmin
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/pgadmin.git
cd pgadmin
sudo docker compose up -d
ln -s /data/blog-frontend/main /data/www
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/nginx-main.git
cd nginx-main
sudo docker compose up -d
cd /data
git clone git@$GIT_SSH_DOMAIN:$GIT_USER/gitea.git
cd gitea
cd /data/utils
bash env-gen.sh GITEA__database__PASSWD
bash init-db.sh gitea $GITEA__database__PASSWD
sudo docker compose up -d
trap - EXIT
echo "Install server-origin complete"