Skip to content

Commit d8901f3

Browse files
committed
Fixed run_cmd
1 parent a6d9b0e commit d8901f3

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

installer.sh

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ run_cmd() {
5656
"$@"
5757
fi
5858
}
59+
5960
# Define templates
6061
LOG_RUNNER_TEMPLATE="rules/flipper-runners.logrotate.template"
6162
UDEV_TEMPLATE="rules/99-udev-flipper-zero.rules.template"
@@ -94,11 +95,8 @@ run_cmd cp -r services/* "$SERVICES_DIR/"
9495
if [ ! -f "$UDEV_RULE" ]; then
9596
echo "Installing udev rule..."
9697
run_cmd cp "$UDEV_TEMPLATE" "$UDEV_RULE"
97-
if [ "$SIMULATE" = true ]; then
98-
echo "SIMULATE: udevadm control --reload-rules && udevadm trigger"
99-
else
100-
udevadm control --reload-rules && udevadm trigger
101-
fi
98+
run_cmd udevadm control --reload-rules
99+
run_cmd udevadm trigger
102100
else
103101
echo "Udev rule already exists, skipping installation."
104102
fi
@@ -108,18 +106,15 @@ if [ ! -f "$BINDER_SERVICE" ]; then
108106
echo "Installing binder service..."
109107
run_cmd cp "$BINDER_TEMPLATE" "$BINDER_SERVICE"
110108
run_cmd cp "$UNBINDER_TEMPLATE" "$UNBINDER_SERVICE"
111-
if [ "$SIMULATE" = true ]; then
112-
echo "SIMULATE: systemctl daemon-reload"
113-
else
114-
run_cmd systemctl daemon-reload
115-
fi
109+
run_cmd systemctl daemon-reload
116110
else
117111
echo "Binder service already exists, skipping installation."
118112
fi
119113

120114
# Install the systemd service using the template.
121115
if [ -f "$SERVICE_TEMPLATE" ]; then
122116
echo "Installing systemd service for Flipper runner..."
117+
# Special handling for the sed command
123118
if [ "$SIMULATE" = true ]; then
124119
echo "SIMULATE: sed -e \"s/__FLIPPER_SERIAL__/${FLIPPER_SERIAL}/g\" -e \"s/__STLINK_SERIAL__/${STLINK_SERIAL}/g\" -e \"s/__GITHUB_RUNNER_TAG__/${GITHUB_TAG}/g\" \"$SERVICE_TEMPLATE\" > \"$SERVICE_FILE\""
125120
else
@@ -132,13 +127,8 @@ fi
132127

133128
# Reload systemd and enable the new service.
134129
echo "Reloading systemd daemon and enabling the service..."
135-
if [ "$SIMULATE" = true ]; then
136-
echo "SIMULATE: systemctl daemon-reload"
137-
echo "SIMULATE: systemctl enable github-runner-flip-${FLIPPER_SERIAL}"
138-
else
139-
run_cmd systemctl daemon-reload
140-
run_cmd systemctl enable "github-runner-flip-${FLIPPER_SERIAL}"
141-
fi
130+
run_cmd systemctl daemon-reload
131+
run_cmd systemctl enable "github-runner-flip-${FLIPPER_SERIAL}"
142132

143133
# Install service binaries
144134
echo "Installing service binaries..."
@@ -148,7 +138,6 @@ run_cmd cp services/flipper-docker-wrapper.sh /usr/local/bin/
148138
run_cmd chmod +x /usr/local/bin/flipper-*.sh
149139

150140
# Install logrotation configuration
151-
152141
echo "Setting up log rotation..."
153142
if [ ! -f "/etc/logrotate.d/github-runners" ]; then
154143
run_cmd cp $LOG_RUNNER_TEMPLATE /etc/logrotate.d/github-runners

monitor-installer.sh

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,9 @@ run_cmd chmod 755 ${METRICS_DIR}
6060

6161
# Set up Python virtual environment
6262
echo "Setting up Python virtual environment..."
63-
if [ "$SIMULATE" = false ]; then
64-
run_cmd python3 -m venv ${VENV_DIR}
65-
run_cmd ${VENV_DIR}/bin/pip install --upgrade pip
66-
run_cmd ${VENV_DIR}/bin/pip install pyudev docker pygelf
67-
else
68-
echo "SIMULATE: Setting up Python virtual environment with pyudev, docker, and pygelf"
69-
fi
63+
run_cmd python3 -m venv ${VENV_DIR}
64+
run_cmd ${VENV_DIR}/bin/pip install --upgrade pip
65+
run_cmd ${VENV_DIR}/bin/pip install pyudev docker pygelf
7066

7167
# Copy the monitoring script
7268
echo "Installing monitoring script..."
@@ -104,13 +100,8 @@ fi
104100

105101
# Reload systemd and enable service
106102
echo "Configuring systemd service..."
107-
if [ "$SIMULATE" = true ]; then
108-
echo "SIMULATE: systemctl daemon-reload"
109-
echo "SIMULATE: systemctl enable github-runner-monitor.service"
110-
else
111-
run_cmd systemctl daemon-reload
112-
run_cmd systemctl enable github-runner-monitor.service
113-
fi
103+
run_cmd systemctl daemon-reload
104+
run_cmd systemctl enable github-runner-monitor.service
114105

115106
echo "Installation complete!"
116107
echo "The monitoring service is now installed and will start on next boot."

0 commit comments

Comments
 (0)