From: Michael Tremer Date: Sat, 8 Sep 2012 14:46:07 +0000 (+0000) Subject: service: Require complete name of systemd unit file. X-Git-Tag: 005~44 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1d08b9b3433434d112a1d6ee1a6505d3315d4402;p=network.git service: Require complete name of systemd unit file. --- diff --git a/bridge-stp b/bridge-stp index 04014b33..fad73816 100755 --- a/bridge-stp +++ b/bridge-stp @@ -38,9 +38,9 @@ fi # Check if mstpd is running. If not, try to start it. if ! service_is_active mstpd; then - service_start mstpd + service_start "mstpd.service" - if ! service_is_active mstpd; then + if ! service_is_active "mstpd.service"; then log ERROR "mstpd is not running. STP might not work." exit 1 fi diff --git a/functions.dhclient b/functions.dhclient index f8f4c12d..d94684a8 100644 --- a/functions.dhclient +++ b/functions.dhclient @@ -26,44 +26,41 @@ dhclient_start() { assert isset interface assert device_exists ${interface} - local service=$(dhclient_proto2service ${proto}) - assert isset service - - service_start "${service}@${interface}" + local service=$(dhclient_proto2service ${proto} ${interface}) + service_start ${service} } dhclient_stop() { local interface=${1} local proto=${2} - local service=$(dhclient_proto2service ${proto}) - assert isset service - - service_stop "${service}@${interface}" + local service=$(dhclient_proto2service ${proto} ${interface}) + service_stop ${service} } dhclient_status() { local interface=${1} local proto=${2} - local service=$(dhclient_proto2service ${proto}) - assert isset service - - service_status "${service}@${interface}" + local service=$(dhclient_proto2service ${proto} ${interface}) + service_status ${service} } dhclient_proto2service() { local proto=${1} assert isset proto + local interface=${2} + assert isset interface + local service case "${proto}" in ipv4) - service="dhclient4" + service="dhclient4@${interface}.service" ;; ipv6) - service="dhclient6" + service="dhclient6@${interface}.service" ;; *) return ${EXIT_ERROR} diff --git a/functions.isdn b/functions.isdn index e8f3d417..8d9a710c 100644 --- a/functions.isdn +++ b/functions.isdn @@ -310,7 +310,7 @@ function ipppd_start() { ipppd_write_config ${device} $@ # Actually run the service. - service_start "ipppd@${device}" + service_start "ipppd@${device}.service" } function ipppd_write_config() { @@ -462,7 +462,7 @@ function ipppd_stop() { local device=${1} # Stop service. - service_stop "ipppd@${device}" + service_stop "ipppd@${device}.service" # Remove configuration file. rm -f $(isdn_config_dir ${device})/config @@ -478,7 +478,7 @@ function ibod_start() { # Start the daemon. log INFO "Starting ibod service on device ${device}." - service_start "ibod@${device}" + service_start "ibod@${device}.service" } function ibod_config_file() { @@ -512,7 +512,7 @@ function ibod_stop() { local device=${1} log INFO "Stopping ibod on device ${device}..." - service_stop "ibod@${device}" + service_stop "ibod@${device}.service" # Remove ibod configuration file. rm -f $(ibod_config_file ${device}) diff --git a/functions.ppp b/functions.ppp index 29a4c965..3e7c0a70 100644 --- a/functions.ppp +++ b/functions.ppp @@ -27,11 +27,11 @@ function pppd_start() { # This will block until the connection has been established or # pppd exited. - service_start "pppd@${interface}" + service_start "pppd@${interface}.service" # Get the exit code of the ppp daemon and figure out # how to handle this. - local ret=$(service_get_exitcode "pppd@${interface}") + local ret=$(service_get_exitcode "pppd@${interface}.service") case "${ret}" in 0) return ${EXIT_OK} @@ -63,14 +63,14 @@ function pppd_stop() { local interface=${1} assert isset interface - service_stop "pppd@${interface}" + service_stop "pppd@${interface}.service" } function pppd_status() { local interface=${1} assert isset interface - service_status "pppd@${interface}" + service_status "pppd@${interface}.service" } function ppp_common_ip_pre_up() { diff --git a/functions.pppoe-server b/functions.pppoe-server index fa1f2835..37c3fdb0 100644 --- a/functions.pppoe-server +++ b/functions.pppoe-server @@ -23,21 +23,21 @@ function pppoe_server_start() { local zone=${1} assert isset zone - service_start "pppoe-server@${zone}" + service_start "pppoe-server@${zone}.service" } function pppoe_server_stop() { local zone=${1} assert isset zone - service_stop "pppoe-server@${zone}" + service_stop "pppoe-server@${zone}.service" } function pppoe_server_status() { local zone=${1} assert isset zone - service_status "pppoe-server@${zone}" + service_status "pppoe-server@${zone}.service" } function pppoe_server_options() { diff --git a/functions.service b/functions.service index 895a1fff..97de2c90 100644 --- a/functions.service +++ b/functions.service @@ -21,48 +21,40 @@ function service_start() { local name=${1} - shift - assert isset name - systemctl start ${name}.service + systemctl start ${name} # Check, if the service was successfully started and # return a proper exit code. service_is_active ${name} local ret=$? - log INFO "Started service '${name}.service', code=${ret}." + log INFO "Started service '${name}', code=${ret}." return ${ret} } function service_stop() { local name=${1} - shift - assert isset name - systemctl stop ${name}.service + systemctl stop ${name} } function service_restart() { local name=${1} - shift - assert isset name - systemctl restart ${name}.service + systemctl restart ${name} } function service_reload() { local name=${1} - shift - assert isset name if service_status ${name}; then - systemctl reload ${name}.service + systemctl reload ${name} return $? else log WARNING "Cannot reload service '${name}' which is currently not running." @@ -71,18 +63,14 @@ function service_reload() { function service_status() { local name=${1} - shift - assert isset name - systemctl status ${name}.service >/dev/null 2>&1 + systemctl status ${name} >/dev/null 2>&1 return $? } function service_is_active() { local name=${1} - shift - assert isset name systemctl is-active ${name}.service >/dev/null 2>&1 @@ -93,8 +81,6 @@ function service_get_exitcode() { local name=${1} assert isset name - name="${name}.service" - local output=$(systemctl show ${name} --property="ExecMainStatus") cli_get_val "${output}" } diff --git a/functions.teredo b/functions.teredo index ca028043..8135597b 100644 --- a/functions.teredo +++ b/functions.teredo @@ -23,7 +23,7 @@ function teredo_start() { local zone=${1} assert isset zone - service_start "miredo-client@${zone}" + service_start "miredo-client@${zone}.service" } function teredo_stop() { @@ -31,7 +31,7 @@ function teredo_stop() { assert isset zone # Just stop the miredo daemon for this device. - service_stop "miredo-client@${zone}" + service_stop "miredo-client@${zone}.service" } function teredo_write_config() { diff --git a/functions.wireless b/functions.wireless index fca2dacb..3ad0677c 100644 --- a/functions.wireless +++ b/functions.wireless @@ -256,7 +256,7 @@ function hostapd_start() { local config_file=${config_dir}/config hostapd_config_write ${device} $@ > ${config_file} - service_start hostapd@${device} + service_start "hostapd@${device}.service" local ret=$? case "${ret}" in @@ -280,10 +280,9 @@ function hostapd_start() { function hostapd_stop() { local device=${1} - assert isset device - service_stop hostapd@${device} + service_stop "hostapd@${device}.service" rm -rf $(hostapd_config_dir ${device}) } diff --git a/functions.zone b/functions.zone index 574ae35c..3a5c60fb 100644 --- a/functions.zone +++ b/functions.zone @@ -78,7 +78,7 @@ function zone_start() { local zone=${1} assert zone_exists ${zone} - service_start "network@${zone}" + service_start "network@${zone}.service" } function zone_stop() { @@ -88,7 +88,7 @@ function zone_stop() { local zone=${1} assert zone_exists ${zone} - service_stop "network@${zone}" + service_stop "network@${zone}.service" } function zone_create() {