3 ##############################
4 ## somenet.org ansible tool ##
5 ##############################
6 # Part of: https://git.somenet.org/root/pub/somesible.git
7 # 2017-2024 by someone <someone@somenet.org>
9 # first-run-pre-requirements:
10 ## git.somenet.org access to somesible repo.
11 ### (presumably: /root/pub/somesible)
15 ## update somesible directory/git-submodule (clone and call update.sh)
16 ## rsync over diversions
18 ## run ansible process
21 SOMESIBLE_OLDPWD=$(pwd)
22 SOMESIBLE_PWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25 if [ -e "update_somesible.sh" ]; then
26 echo "*** ERROR (run_somesible.sh): this is not supposed to be run inside the somesible git repo. abort."
30 # (try to) read config in parent dir.
31 if [ -e "somesible.conf" ]; then
36 # delete old lock-file, if too old, allowing to run the update.
37 find "/tmp/run_somesible_${USER}.sh.lock" -mmin +60 -delete >/dev/null 2>&1
38 if [ -e "/tmp/run_somesible_${USER}.sh.lock" ]; then
39 echo "*** EARLY EXIT: /tmp/run_somesible_${USER}.sh.lock is too new"
40 echo 'maybe need to: rm -f "/tmp/run_somesible_${USER}.sh.lock"'
44 ###################################
45 # update or clone and reset repos #
46 ###################################
47 git config fetch.recurseSubmodules false
49 if [ ! -e "$SOMESIBLE_PWD/somesible/.git" ]; then
50 echo "*** WARN (run_somesible.sh): somesible git repo not found. cloning..."
51 git clone git@git.somenet.org:/root/pub/somesible somesible
54 cd $SOMESIBLE_PWD/somesible || { echo "*** ERROR (run_somesible.sh): Tried to get a clone of somesible, but it still does not exist. Aborting. ***"; exit 1;}
55 # allow to skip updating.
56 if [ -z "$SOMESIBLE_SKIP_UPDATE" ]; then
57 #(nohup sh ./update_somesible.sh </dev/null >>/dev/null 2>&1)
58 sh ./update_somesible.sh
60 rsync -qclDP "${SOMESIBLE_PWD}/somesible/run_somesible.sh" "${SOMESIBLE_PWD}/"
65 #########################
66 # rsync over diversions #
67 #########################
68 mkdir -p "${SOMESIBLE_PWD}/override/"
69 rsync -qcrlDP "${SOMESIBLE_PWD}/override/" "${SOMESIBLE_PWD}/somesible/"
75 cd $SOMESIBLE_PWD/somesible
77 # currently its not possible to have conditional playbook includes.
79 if [ -e "${SOMESIBLE_PWD}/site.yml" ]; then
80 ansible-playbook site_parent.yml -l managed "$@"
82 ansible-playbook site_base.yml -l managed "$@"
86 rm -f "/tmp/run_somesible_${USER}.sh.lock"