70 lines
2.9 KiB
Bash
Executable File
70 lines
2.9 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
|
|
gitrepo=$3 # url to get apxtri code from a git repo (empty if must come from a backup or the url)
|
|
|
|
# get
|
|
wget "${url}/${tribe}/setup.objects.tar.gz"
|
|
if [[ $? -eq 0 ]]; then
|
|
echo "Check the url:$url seems not answer"
|
|
urlko=1
|
|
fi
|
|
if [[ "$urlok" -eq 1 || -z "$tribe" ]]; then
|
|
echo "Need more params, cmd must be $ . setup.sh <tribename> <url to get data> <gitrepourl>"
|
|
echo "Example1: . setup.sh adminapi https://testwall-ants.ndda.fr https://gitea.ndda.fr/apxtri/adminapi"
|
|
echo " install adminapi from the repo (with git accessright) and get data for adminapi from testwall-ants.nnda.fr"
|
|
echo "Example2: setup.sh smatchit https://testwall-ants.ndda.fr"
|
|
echo " install smatchit as a copy of testwall-ants.ndda.fr but not from the git (you don't need to have git acess but need to know a specific code)"
|
|
else
|
|
if [ -z "$gitrepo" ]; then
|
|
wget "${url}/${tribe}/setup.apxtri.tar.gz"
|
|
tar -xzf setup.apxtri.tar.gz -C . -p && rm setup.apxtri.tar.gz
|
|
wget "${url}/${tribe}/setup.schema.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
|
|
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}/backups"
|
|
# add 127.0.0.1 local host
|
|
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
|
|
cd "$tribe"
|
|
yarn install
|
|
cd ../adminapi
|
|
yarn dev
|
|
fi
|