1 |
# $Id$ |
# $Id$ |
2 |
|
|
3 |
provide basic-system |
provide basic-system |
4 |
|
require basic-init |
5 |
|
|
6 |
help_system_reboot() |
help_system_reboot() |
7 |
{ |
{ |
36 |
mecho " root - mcore root user with full system privileges" |
mecho " root - mcore root user with full system privileges" |
37 |
} |
} |
38 |
|
|
|
help_system_passwd() |
|
|
{ |
|
|
mecho "set system.passwd [user] [password]" |
|
|
mecho " Sets a system password for given user." |
|
|
mecho " Allowed users: ${MCORE_UNPRIV_USER}, root" |
|
|
mecho " If password is empty, the current password will be deleted." |
|
|
} |
|
|
|
|
39 |
help_system_autologon() |
help_system_autologon() |
40 |
{ |
{ |
41 |
mecho "get system.autologon" |
mecho "get system.autologon" |
80 |
mecho " del - deletes a service from all runlevels" |
mecho " del - deletes a service from all runlevels" |
81 |
} |
} |
82 |
|
|
83 |
helper_set_system_service_sysvinit() |
help_system_passwd() |
|
{ |
|
|
local command="$1" |
|
|
local service="$2" |
|
|
local opts="$3" |
|
|
|
|
|
[[ -z ${command} ]] && help_system_service && return 1 |
|
|
[[ -z ${service} ]] && help_system_service && return 1 |
|
|
|
|
|
if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]] |
|
|
then |
|
|
eecho "Service '${service}' unkown!" |
|
|
return 1 |
|
|
fi |
|
|
|
|
|
case "${command}" in |
|
|
start) /etc/rc.d/init.d/"${service}" start ;; |
|
|
stop) /etc/rc.d/init.d/"${service}" stop ;; |
|
|
restart) /etc/rc.d/init.d/"${service}" restart ;; |
|
|
reload) /etc/rc.d/init.d/"${service}" reload ;; |
|
|
add) rc-config add "${service}" ;; |
|
|
del) rc-config del "${service}" ;; |
|
|
*) help_system_service && return ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
helper_set_system_service_systemd() |
|
|
{ |
|
|
local command="$1" |
|
|
local service="$2" |
|
|
local opts="$3" |
|
|
|
|
|
[[ -z ${command} ]] && help_system_service && return 1 |
|
|
[[ -z ${service} ]] && help_system_service && return 1 |
|
|
|
|
|
if [[ -n $(systemctl status ${service} | grep 'Reason: No such file or directory') ]] |
|
|
then |
|
|
eecho "Service '${service}' unkown!" |
|
|
return 1 |
|
|
fi |
|
|
|
|
|
case "${command}" in |
|
|
start) systemctl start "${service}" ;; |
|
|
stop) systemctl stop "${service}" ;; |
|
|
restart) systemctl try-restart "${service}" ;; |
|
|
reload) systemctl reload-or-try-restart "${service}" ;; |
|
|
add) systemctl enable "${service}" ;; |
|
|
del) systemctl disable "${service}" ;; |
|
|
*) help_system_service && return ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
set_system_service() |
|
|
{ |
|
|
if [[ -x $(type -P systemctl) ]] |
|
|
then |
|
|
helper_set_system_service_systemd $* |
|
|
else |
|
|
helper_set_system_service_sysvinit $* |
|
|
fi |
|
|
} |
|
|
|
|
|
helper_get_system_service_sysvinit() |
|
|
{ |
|
|
local command="$1" |
|
|
local service="$2" |
|
|
|
|
|
[[ -z ${command} ]] && help_system_service && return 1 |
|
|
[[ -z ${service} ]] && help_system_service && return 1 |
|
|
|
|
|
if [[ ! -x ${MROOT}/etc/rc.d/init.d/${service} ]] |
|
|
then |
|
|
eecho "Service '${service}' unkown!" |
|
|
return 1 |
|
|
fi |
|
|
|
|
|
case "${command}" in |
|
|
status) /etc/rc.d/init.d/"${service}" status ;; |
|
|
enabled) rc-config show "${service}" ;; |
|
|
runlevel) eecho "function on todo" ;; |
|
|
*) help_system_service && return ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
helper_get_system_service_systemd() |
|
|
{ |
|
|
local command="$1" |
|
|
local service="$2" |
|
|
|
|
|
[[ -z ${command} ]] && help_system_service && return 1 |
|
|
[[ -z ${service} ]] && help_system_service && return 1 |
|
|
|
|
|
if [[ -n $(systemctl status ${service} | grep 'Reason: No such file or directory') ]] |
|
|
then |
|
|
eecho "Service '${service}' unkown!" |
|
|
return 1 |
|
|
fi |
|
|
|
|
|
case "${command}" in |
|
|
status) systemctl status "${service}" ;; |
|
|
enabled) systemctl is-enabled "${service}"; rvecho "$?" ;; |
|
|
runlevel) rvecho "$(readline ${MROOT}/etc/systemd/system/default.target)" ;; |
|
|
*) help_system_service && return ;; |
|
|
esac |
|
|
} |
|
|
|
|
|
get_system_service() |
|
84 |
{ |
{ |
85 |
if [[ -x $(type -P systemctl) ]] |
mecho "set system.passwd [user] [password]" |
86 |
then |
mecho " Sets a system password for given user." |
87 |
helper_get_system_service_systemd $* |
mecho " Allowed users: ${MCORE_UNPRIV_USER}, root" |
88 |
else |
mecho " If password is empty, the current password will be deleted." |
|
helper_get_system_service_sysvinit $* |
|
|
fi |
|
89 |
} |
} |
90 |
|
|
91 |
set_system_passwd() |
set_system_passwd() |