Skip to content

Commit 58adf8c

Browse files
committed
testing
1 parent b24ed19 commit 58adf8c

File tree

3 files changed

+34
-7
lines changed

3 files changed

+34
-7
lines changed

github-runner/node-runner.sh

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ set -o errtrace # Trap ERR in functions and subshells
1616
trap 'echo "❌ Script failed on line $LINENO with exit code $?"' ERR
1717

1818
# --- DEFAULTS ---
19-
RUNNER_NAME="$(hostname)-runner"
2019
RUNNER_DIR="/opt/github-runner"
21-
20+
RUNAS_USER="provision"
21+
RUNAS_GROUP="application"
2222
# --- USAGE ---
2323
usage() {
2424
echo "Usage: $0 [OPTIONS]"
@@ -62,7 +62,7 @@ done
6262
[[ "${SCOPE}" == "repo" && -z "${REPO_NAME:-}" ]] && read -rp "Repository name: " REPO_NAME
6363
[[ -z "${GITHUB_TOKEN:-}" ]] && read -rsp "GitHub token (no echo): " GITHUB_TOKEN && echo
6464
[[ -z "${SCOPE:-}" ]] && read -rp "Scope (repo|org) [repo]: " SCOPE && SCOPE="${SCOPE:-repo}"
65-
65+
[[ -z "${RUNNER_NAME:-}" ]] && RUNNER_NAME="$(hostname)-runner"
6666

6767
# --- Add runner labels ---
6868
LABELS="self-hosted,linux,node,${ENV}"
@@ -125,8 +125,8 @@ REG_TOKEN=$(curl -s -X POST \
125125
"${REG_URL}" | jq -r .token)
126126

127127
# --- CONFIGURE RUNNER ---
128-
echo "[+] Configuring runner..."
129-
sudo -u $RUNAS_USER ./config.sh \
128+
echo "[+] Configuring runner ${RUNNER_NAME}..."
129+
./config.sh \
130130
--unattended \
131131
--url "${RUNNER_SCOPE}" \
132132
--token "${REG_TOKEN}" \
@@ -136,8 +136,22 @@ sudo -u $RUNAS_USER ./config.sh \
136136

137137
# --- SETUP SYSTEMD SERVICE ---
138138
echo "[+] Installing systemd service..."
139-
export SUDO_USER=$RUNAS_USER
139+
140140
sudo ./svc.sh install
141+
142+
# Detect the systemd service name
143+
SERVICE_FILE_PATH=$(ls /etc/systemd/system/actions.runner.*.service 2>/dev/null | head -n1)
144+
145+
if [[ -n "$SERVICE_FILE_PATH" ]]; then
146+
echo "[+] Updating systemd unit to run as ${RUNAS_USER}:${RUNAS_GROUP}..."
147+
sudo sed -i "s/^User=.*/User=${RUNAS_USER}/" "$SERVICE_FILE_PATH"
148+
sudo sed -i "s/^Group=.*/Group=${RUNAS_GROUP}/" "$SERVICE_FILE_PATH"
149+
sudo systemctl daemon-reload
150+
else
151+
echo "⚠️ Could not find service file automatically — please verify installation."
152+
fi
153+
154+
141155
sudo ./svc.sh start
142156

143157
echo "✅ Runner '${RUNNER_NAME}' is installed and started!"

scripts/bootstrap/create-provision-user.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ if [[ -n "$sudo_access" ]]; then
8686
log "✅ User '$USER_NAME' already has full sudo access."
8787
else
8888
log "🚀 Granting full sudo access to user '$USER_NAME'..."
89-
log "${USER_NAME} ALL=(ALL:ALL) ALL" | sudo tee /etc/sudoers.d/$USER_NAME > /dev/null
89+
log "${USER_NAME} ALL=(ALL:ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/$USER_NAME > /dev/null
9090
sudo chmod 0440 /etc/sudoers.d/$USER_NAME
9191
fi
9292

@@ -105,8 +105,13 @@ else
105105
sudo -u $USER_NAME ssh-keygen -t ed25519 -f /home/$USER_NAME/.ssh/id_ed25519 -N "" -C "${USER_NAME}@$(hostname)"
106106
fi
107107
fi
108+
109+
if [ -f /home/$USER_NAME/.ssh/id_ed25519.pub ]; then
108110
log "
109111
⚠️ ⚠️ ⚠️ ⚠️ ⚠️ Store the following public key for later usage ⚠️ ⚠️ ⚠️ ⚠️ ⚠️
110112
⚙️ $USER_NAME SSH key pair public key (add on worker nodes if needed):
111113
"
112114
sudo cat /home/$USER_NAME/.ssh/id_ed25519.pub
115+
fi
116+
117+
echo "✅ User/Group setup completed."

scripts/bootstrap/opencrvs-bootstrap.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ MIN_UBUNTU_VERSION="24.04"
1111
# --- Helper Functions --- #
1212
abort() { echo "ERROR: $1"; exit 1; }
1313

14+
while [[ $# -gt 0 ]]; do
15+
case "$1" in
16+
--ssh-public-key) SSH_PUBLIC_KEY="$2"; shift 2 ;;
17+
-h|--help) usage ;;
18+
*) echo "Unknown option: $1"; usage ;;
19+
esac
20+
done
21+
1422
check_ubuntu_version() {
1523
echo "Checking Ubuntu version..."
1624
UBUNTU_VERSION=$(lsb_release -rs)

0 commit comments

Comments
 (0)