jean-cloud-services/services/core.oma-radio.fr/deploy_user.sh
2025-10-31 18:49:12 +01:00

56 lines
1.2 KiB
Bash
Executable File

#!/bin/bash
set -euo pipefail
# Add ssh fingerprint
if [ ! -e ~/.ssh/known_hosts ] ; then
mkdir -p ~/.ssh
ssh-keyscan -p 22 gitlab.com > ~/.ssh/known_hosts
cp "$SECRET_DIR/gitlab-deploy.sshprivkey" ~/.ssh/id_rsa
fi
new_content=false
# Clone if needed
if [ ! -d "$DATA_DIR/core" ] ; then
cd "$DATA_DIR"
git clone git@gitlab.com:omaradio/core.git
cd core
new_content=true
else
cd "$DATA_DIR/core"
fi
# Set mtime of last modifying commit
gitmtim(){ local f;for f;do touch -d @0`git log --pretty=%at -n1 -- "$f"` "$f"; done;}
# Loop eche branch
for branch in dev recette ; do
git checkout -f "$branch"
# Check for new stuff
if ! git pull | grep -q 'Already up to date.' ; then
new_content=true
fi
# Clean repo
git clean -dfx
# Create bonus if needed
dest="$DATA_DIR/bonus-$branch"
if "$new_content" || [ ! -d $dest ] ; then
# Set git mtime for bonus files
cd "$DATA_DIR/core/"
for bonusdir in $(find "$DATA_DIR/core/radioDemo/" -type d -name 'importBonus*') ; do
gitmtim $(find "$bonusdir")
done
echo "Creating bonus to $dest"
mkdir -p "$dest"
cd "$DATA_DIR/core/radioDemo/"
./cfg_local/scripts/create_bonuses.sh "$DATA_DIR/core/radioDemo" "$dest"
fi
done
echo "OK. Tous les bonus sont générés."