-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·67 lines (48 loc) · 1.4 KB
/
install.sh
File metadata and controls
executable file
·67 lines (48 loc) · 1.4 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
set -e
set -o pipefail
: "${REPO_URL:="https://github.com/flaudisio/linux-setup-playbook.git"}"
: "${BRANCH:="main"}"
: "${INSTALL_DIR:="${HOME}/.local/share/linux-setup-playbook"}"
function _msg()
{
echo "$*" >&2
}
function _run()
{
_msg "+ $*"
"$@"
}
function main()
{
_msg "==> Installing dependencies"
_run sudo apt-get update -q
_run sudo apt-get install -q -y curl git
if [[ ! -d "$INSTALL_DIR" ]] ; then
_msg "==> Cloning repository"
_run git clone -b "$BRANCH" "$REPO_URL" "$INSTALL_DIR"
else
_msg "==> Directory '$INSTALL_DIR' already exists, updating repository"
_run git -C "$INSTALL_DIR" switch main
_run git -C "$INSTALL_DIR" pull origin main
fi
if ! command -v mise > /dev/null ; then
_msg "==> Installing mise-en-place"
_run curl -f -sSL https://mise.run | bash
fi
_msg "==> Installing Ansible and project dependencies"
_run export PATH="${HOME}/.local/bin:${PATH}"
_run mise -C "$INSTALL_DIR" trust --yes
_run mise -C "$INSTALL_DIR" install
_run mise -C "$INSTALL_DIR" run install
_msg
cat << EOM
--------------------------------------------------
Ansible successfully installed!
Use the following commands to run the playbook:
cd $INSTALL_DIR
./run playbooks/default.yml --list-tasks
--------------------------------------------------
EOM
}
main "$@"