-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·50 lines (41 loc) · 1.15 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
check_mode=""
usage() {
cat << EOF
Usage: install.sh [OPTIONS]
Options:
-C, --check Run the playbook in check mode (dry run)
EOF
exit 1
}
# Check for --check or -C option
if [[ -n $1 ]]; then
case $1 in
-C|--check)
check_mode="--check"
;;
*)
usage
;;
esac
fi
# Fetch latest changes from the remote repository
git fetch > /dev/null
local_head=$(git rev-parse HEAD)
remote_head=$(git rev-parse @{u})
base=$(git merge-base HEAD @{u})
if [ "$local_head" = "$remote_head" ]; then
echo "Local repository is up to date with remote."
else
echo ''
if [ "$local_head" = "$base" ]; then
echo "Update available. Run \"git pull\" to update to the latest version."
elif [ "$remote_head" = "$base" ]; then
echo "Local commits detected. You are ahead of the remote. Consider pushing your changes."
else
echo "Your local and remote branches have diverged. Consider merging the remote changes."
fi
sleep 5s
fi
script_root="$(realpath "$(dirname "$0")")"
sudo $(which poetry) run ansible-playbook "$script_root/workstation.yml" $check_mode