-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wip/bashscript refactoring #348
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
${{header}} | ||
${{loader-functions}} | ||
${{control-functions}} | ||
|
||
addGroup ${{daemon_group}} | ||
addUser ${{daemon_user}} ${{daemon_group}} "${{app_name}} user-daemon" "${{daemon_shell}}" | ||
|
||
${{chown-paths}} | ||
|
||
startService ${{app_name}} || echo "${{app_name}} could not be registered or started" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
${{header}} | ||
${{control-functions}} | ||
|
||
# Deleting user: ${{daemon_user}} and group: ${{daemon_group}} | ||
case "$1" in | ||
remove|failed-upgrade|abort-upgrade|abort-install|disappear) | ||
;; | ||
purge) | ||
deleteUser ${{daemon_user}} | ||
deleteGroup ${{daemon_group}} | ||
;; | ||
upgrade) | ||
;; | ||
*) | ||
echo "postinst called with unknown argument \`\$1'" >&2 | ||
;; | ||
esac |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
${{header}} | ||
${{control-functions}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
${{header}} | ||
${{loader-functions}} | ||
|
||
stopService ${{app_name}} || echo "${{app_name}} wasn't even running!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
${{loader-functions}} | ||
${{control-functions}} | ||
|
||
addGroup ${{daemon_group}} | ||
addUser ${{daemon_user}} ${{daemon_group}} "${{app_name}} user-daemon" "${{daemon_shell}}" | ||
|
||
startService ${{app_name}} || echo "${{app_name}} could not be registered or started" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Halting ${{app_name}} | ||
echo "Shutdown ${{app_name}}" | ||
service ${{app_name}} stop || echo "Could not stop ${{app_name}}" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Adding service to autostart | ||
# $1 = service name | ||
# | ||
startService() { | ||
app_name=$1 | ||
systemctl enable "$app_name.service" | ||
systemctl start "$app_name.service" | ||
} | ||
|
||
# | ||
# Removing service from autostart | ||
# $1 = service name | ||
# | ||
stopService() { | ||
app_name=$1 | ||
systemctl disable "$app_name.service" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,4 +10,4 @@ Restart=always | |
RestartSec=${{retryTimeout}} | ||
|
||
[Install] | ||
WantedBy=multi-user.target | ||
WantedBy=multi-user.target |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# | ||
# Adding service to autostart | ||
# $1 = service name | ||
# | ||
startService() { | ||
app_name=$1 | ||
if hash update-rc.d 2>/dev/null; then | ||
echo "Adding $app_name to autostart using update-rc.d" | ||
update-rc.d $app_name defaults | ||
service $app_name start | ||
elif hash chkconfig 2>/dev/null; then | ||
echo "Adding $app_name to autostart using chkconfig" | ||
chkconfig --add ${{app_name}} | ||
chkconfig $app_name on | ||
service $app_name start | ||
else | ||
echo "WARNING: Could not put $app_name in autostart: update-rc and chkconfig or found!" | ||
fi | ||
} | ||
|
||
# | ||
# Removing service from autostart | ||
# $1 = service name | ||
# | ||
stopService() { | ||
app_name=$1 | ||
service $app_name stop | ||
if hash update-rc.d 2>/dev/null; then | ||
echo "Removing $app_name from autostart using update-rc.d" | ||
update-rc.d -f $app_name remove | ||
service $app_name stop | ||
elif chkconfig 2>/dev/null; then | ||
echo "Removing $app_name from autostart using chkconfig" | ||
chkconfig $app_name off | ||
chkconfig --del $app_name | ||
service $app_name stop | ||
else | ||
echo "WARNING: Could not put $app_name in autostart: update-rc or chkconfig not found!" | ||
fi | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# | ||
# Adding service to autostart | ||
# $1 = service name | ||
# | ||
startService() { | ||
app_name=$1 | ||
initctl reload-configuration | ||
service $app_name start | ||
} | ||
|
||
# | ||
# Removing service from autostart | ||
# $1 = service name | ||
# | ||
stopService() { | ||
app_name=$1 | ||
service $app_name stop | ||
} |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely like this idea a lot, splitting the template into re-usable components....
If only we could auto-document this stuff...