-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·41 lines (32 loc) · 1.19 KB
/
setup.sh
File metadata and controls
executable file
·41 lines (32 loc) · 1.19 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
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# ---------------------------------------------------------------------------
# Helpers
# ---------------------------------------------------------------------------
log() { echo "[setup] $*"; }
is_ubuntu_debian() {
[[ -f /etc/os-release ]] && grep -qiE 'ubuntu|debian' /etc/os-release
}
# Keep sudo credentials alive for the duration of the script.
# Prompts once at the start; a background heartbeat refreshes every 50s.
sudo_keepalive() {
sudo true
(while true; do sudo -n true; sleep 50; done) &
SUDO_KEEPALIVE_PID=$!
trap 'kill "$SUDO_KEEPALIVE_PID" 2>/dev/null' EXIT
}
# ---------------------------------------------------------------------------
# Main
# ---------------------------------------------------------------------------
if is_ubuntu_debian; then
log "Ubuntu/Debian detected — will run setup_ubuntu.sh first (requires sudo)"
sudo_keepalive
log "Running setup_ubuntu.sh..."
sudo --preserve-env=HOME,USER bash "$SCRIPT_DIR/setup_ubuntu.sh"
log "setup_ubuntu.sh complete"
fi
log "Running setup_dev.sh..."
bash "$SCRIPT_DIR/setup_dev.sh"
log "setup_dev.sh complete"
log "Done."