Skip to content

Commit 81f6e82

Browse files
rjpadilladogi
andauthored
treehouses container refactor (fixes #2055) (#2062)
Co-authored-by: dogi <dogi@users.noreply.github.com>
1 parent ada452c commit 81f6e82

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

modules/globals.sh

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
function start_service {
2-
if [ "$(systemctl is-active "$1" 2>"$LOGFILE")" = "inactive" ]
3-
then
4-
systemctl start "$1" >"$LOGFILE" 2>"$LOGFILE"
2+
if [ "$(systemctl is-active "$1" 2>"$LOGFILE")" = "inactive" ]; then
3+
systemctl start "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to start service $1"
54
fi
65
}
76

87
function restart_service {
9-
systemctl stop "$1" >"$LOGFILE" 2>"$LOGFILE"
10-
systemctl start "$1" >"$LOGFILE" 2>"$LOGFILE"
8+
systemctl stop "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to stop service $1"
9+
systemctl start "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to start service $1"
1110
}
1211

1312
function stop_service {
14-
if [ "$(systemctl is-active "$1" 2>"$LOGFILE")" = "active" ]
15-
then
16-
systemctl stop "$1" >"$LOGFILE" 2>"$LOGFILE"
13+
if [ "$(systemctl is-active "$1" 2>"$LOGFILE")" = "active" ]; then
14+
systemctl stop "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to stop service $1"
1715
fi
1816
}
1917

2018
function enable_service {
21-
if [ "$(systemctl is-enabled "$1" 2>"$LOGFILE")" = "disabled" ]
22-
then
23-
systemctl enable "$1" >"$LOGFILE" 2>"$LOGFILE"
19+
if [ "$(systemctl is-enabled "$1" 2>"$LOGFILE")" = "disabled" ]; then
20+
systemctl enable "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to enable service $1"
2421
fi
2522
}
2623

2724
function disable_service {
2825
if [ "$(systemctl is-enabled "$1" 2>"$LOGFILE")" = "enabled" ]; then
29-
systemctl disable "$1" >"$LOGFILE" 2>"$LOGFILE"
26+
systemctl disable "$1" >"$LOGFILE" 2>"$LOGFILE" || log_and_exit1 "Failed to disable service $1"
3027
fi
3128
}
3229

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@treehouses/cli",
3-
"version": "1.25.20",
3+
"version": "1.25.21",
44
"remote": "4000",
55
"description": "Thin command-line interface for Raspberry Pi low level configuration.",
66
"main": "cli.sh",

0 commit comments

Comments
 (0)