Skip to content

Commit

Permalink
Add a helper script to restart all daemons and sockets
Browse files Browse the repository at this point in the history
  • Loading branch information
mbuesch committed Jan 17, 2025
1 parent 285eb28 commit f15b6b7
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions restart.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/sh
# -*- coding: utf-8 -*-

basedir="$(realpath "$0" | xargs dirname)"

info()
{
echo "--- $*"
}

error()
{
echo "=== ERROR: $*" >&2
}

warning()
{
echo "=== WARNING: $*" >&2
}

die()
{
error "$*"
exit 1
}

entry_checks()
{
[ "$(id -u)" = "0" ] || die "Must be root to restart letmein."
}

do_systemctl()
{
info "systemctl $*"
systemctl "$@" || die "Failed to systemctl $*"
}

try_systemctl()
{
info "systemctl $*"
systemctl "$@" 2>/dev/null
}

stop_services()
{
try_systemctl stop letmeind.socket
try_systemctl stop letmeind.service
try_systemctl stop letmeinfwd.socket
try_systemctl stop letmeinfwd.service
try_systemctl disable letmeind.service
try_systemctl disable letmeind.socket
try_systemctl disable letmeinfwd.service
try_systemctl disable letmeinfwd.socket
}

start_services()
{
do_systemctl start letmeinfwd.socket
do_systemctl start letmeinfwd.service
do_systemctl start letmeind.socket
do_systemctl start letmeind.service
}

entry_checks
stop_services
start_services

# vim: ts=4 sw=4 expandtab

0 comments on commit f15b6b7

Please sign in to comment.