-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh.template
More file actions
35 lines (29 loc) · 865 Bytes
/
setup.sh.template
File metadata and controls
35 lines (29 loc) · 865 Bytes
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
#!/bin/bash
set -Eeuxo pipefail
## Variables
SCRIPT_EXTRA_ACTION="${1:-}"
GH_USER="${GH_USER:-$(id -un)}"
GH_RUNNER_DIR="${GH_RUNNER_DIR:-actions-runner}"
VM_USERNAME="{{vm_username}}"
# Make sure script is run as non root
if [[ $UID = 0 ]]; then
regular_user="$(id -un -- 1000)"
chown "${regular_user}" "$0"
su -c "bash '$0'" "${regular_user}"
exit 0
fi
if [[ ${SCRIPT_EXTRA_ACTION} == '--destroy' ]]; then
cd "/${GH_RUNNER_DIR}"
sudo ./svc.sh uninstall
./config.sh remove --token {{token}}
exit 0
fi
## Update User Permissions
sudo usermod -aG docker "${VM_USERNAME}"
sudo usermod -aG docker "${GH_USER}"
## GitHub Runner
cd "/${GH_RUNNER_DIR}"
export RUNNER_ALLOW_RUNASROOT=1
./config.sh --unattended --url https://github.com/{{repo}} --token {{token}} --labels {{label}} --replace
sudo ./svc.sh install
sudo ./svc.sh start