95 lines
4.1 KiB
Bash
Executable File
95 lines
4.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Installation process from an existing backup to set up a new
|
|
# See README.md for full process
|
|
#
|
|
# Create in apxtowns a town-nations
|
|
# wget {any instance url}/setup.sh
|
|
# chmode +x setup.sh
|
|
# ./setup.sh mode tribe url
|
|
# Example:
|
|
# To set up a new towns with tribe adminapi from the git repo
|
|
# To be use as a dev plateforme for apxtri
|
|
# To sync only data in existing install check in /obejcts/rsync.sh
|
|
# .setup.sh adminapi https://testwall-ants.ndda.fr https://gitea.ndda.fr/apxtri/adminapi
|
|
#
|
|
# Make a copy (so must manage versioning by running the same command to update
|
|
# carefull it erase the data object with the one it gets)
|
|
# To be use for production purpose
|
|
# .setup.sh adminapi https://testwall-ants.ndda.fr
|
|
#
|
|
# Create a new instance of smatchit from an existing production env
|
|
# .setup.sh smatchit https://testwall-ants.ndda.fr
|
|
#
|
|
# Create a dev en from git repo
|
|
# .setup.sh smatchit https://testwall-ants.ndda.fr https://gitea.ndda.fr/smatchit/smatchit
|
|
|
|
tribe=$1 # name of the tribe to install
|
|
url=$2 # url to get the data from OR newtribe
|
|
gitrepo=$3 # url to get apxtri code from a git repo (empty if must come from a backup or the url)
|
|
codekey=$4 # code to access backend of the tribe in case it is not newtribe or adminapi tribe
|
|
|
|
function help {
|
|
echo "Need more params, cmd must be $ . setup.sh <tribename> <url to get data> <gitrepourl> <codekey to getdata>"
|
|
echo "Example1: . setup.sh adminapi https://app1.smatchit.io https://gitea.ndda.fr/apxtri/adminapi"
|
|
echo " install adminapi from the repo (with git accessright) and get data for adminapi from app1.smatchit.io"
|
|
echo "Example2: setup.sh smatchit https://admin.smatchit.io 1234"
|
|
echo " install smatchit as a copy of admin.smatchit.io but not from the git (you don't need to have git acess but need to know a specific code like 1234)"
|
|
echo "Example3: setup.sh smatchit newtribe"
|
|
echo " create a new empty tribe"
|
|
}
|
|
|
|
if [ -z "$tribe" ]; then
|
|
echo "Tribe must be defined"
|
|
help
|
|
else
|
|
if [ "$url" == "newtribe" ]; then
|
|
mkdir -p "${tribe}"
|
|
else
|
|
wget "${url}/${tribe}/backups/setup.objects.tar.gz?code=${codekey}" -O setup.objects.tar.gz
|
|
if [[ $? -ne 0 ]]; then
|
|
echo "Check the url:$url that seems not answer, check with tribe's admin if your access code is still valid"
|
|
help
|
|
else
|
|
# add 127.0.0.1 town.nation in /ertc/hoss if not already exist to make localhost available
|
|
#dns=$(basename "$PWD" | sed 's/-/./g')
|
|
#grep -q "^127.0.0.1 $dns" /etc/hosts || echo "127.0.0.1 $dns" | sudo tee -a /etc/hosts > /dev/null
|
|
if [ -z "$gitrepo" ]; then
|
|
wget "${url}/${tribe}/backups/setup.apxtri.tar.gz?code=${codekey}" -O setup.objects.tar.gz
|
|
tar -xzf setup.apxtri.tar.gz -C . -p && rm setup.apxtri.tar.gz
|
|
wget "${url}/${tribe}/backups/setup.schema.tar.gz?code=${codekey}" -O setup.objects.tar.gz
|
|
tar -xzf setup.schema.tar.gz -C . -p && rm setup.schema.tar.gz
|
|
#wget "${url}/${tribe}/setup.nginx.tar.gz"
|
|
#tar -xzf setup.nginx.tar.gz -C . -p && rm setup.nginx.tar.gz
|
|
#echo "please change your dns accordingly with ${tribe}/nginx/ conf file"
|
|
else
|
|
git clone "$gitrepo"
|
|
fi
|
|
tar -xzf setup.objects.tar.gz -C . -p && rm setup.objects.tar.gz
|
|
fi
|
|
fi
|
|
mkdir -p "${tribe}/objects/persons"
|
|
mkdir -p "${tribe}/objects/persons/itm"
|
|
mkdir -p "${tribe}/objects/persons/idx"
|
|
mkdir -p "${tribe}/tmp"
|
|
mkdir -p "${tribe}/logs"
|
|
mkdir -p "${tribe}/logs/nginx"
|
|
mkdir -p "${tribe}/logs/apxtri"
|
|
mkdir -p "${tribe}/logs/pytri"
|
|
mkdir -p "${tribe}/backups"
|
|
# add specific dependancy for tribe if apxtri exist
|
|
cd "$tribe"
|
|
if [ -d "$PWD/apxtri" ]; then
|
|
nvm install --lts
|
|
nvm use --lts
|
|
yarn install
|
|
fi
|
|
if [ -d "$PWD/pytri" ]; then
|
|
sudo apt install python3-venv -y
|
|
python3 -m venv pythonenv
|
|
echo "Python virtual env venv installed, don't forget to use $ source ${tribe}/pythonenv/bin/activate; before running any python script then $ deactivate"
|
|
fi
|
|
# run as dev that will create missing file to make it works
|
|
cd ../adminapi
|
|
yarn dev
|
|
fi
|