Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
0477798c9e
|
|||
750cde1aa1
|
|||
16f8b86d1b
|
|||
3bd632a39b
|
|||
b17e0376bc
|
@@ -21,6 +21,8 @@ Quick Examples:
|
|||||||
- `rsm enable <svc>` - enable a service (autostart at boot)
|
- `rsm enable <svc>` - enable a service (autostart at boot)
|
||||||
- `rsm disable <svc>` - disable a service (no autostart at boot)
|
- `rsm disable <svc>` - disable a service (no autostart at boot)
|
||||||
- `rsm hup <svc>` - refresh a service (`SIGHUP`)
|
- `rsm hup <svc>` - refresh a service (`SIGHUP`)
|
||||||
|
- `rsm logs <svc>` or `rsm alllogs <svc>` - lists all logs for a service (access and error)
|
||||||
|
- `rsm errorlogs <svc>` - lists all error logs for a service
|
||||||
|
|
||||||
Status:
|
Status:
|
||||||
|
|
||||||
|
101
rsm
101
rsm
@@ -9,9 +9,11 @@
|
|||||||
# Date: August 29, 2018
|
# Date: August 29, 2018
|
||||||
# License: MIT
|
# License: MIT
|
||||||
|
|
||||||
RSM_VERSION='v1.3.9'
|
RSM_VERSION='v1.4.2'
|
||||||
|
|
||||||
export SVDIR=${SVDIR:-/run/runit/service/}
|
export SVDIR=${SVDIR:-/run/runit/service/}
|
||||||
|
export LOGDIR="/var/log/"
|
||||||
|
export RSVDIR="/run/runit/service/"
|
||||||
export FLDIR=${FLDIR:-/etc/runit/sv/}
|
export FLDIR=${FLDIR:-/etc/runit/sv/}
|
||||||
|
|
||||||
|
|
||||||
@@ -166,6 +168,10 @@ ${colorgreen}start <service> $cr Start the service
|
|||||||
${colorgreen}stop <service> $cr Stop the service
|
${colorgreen}stop <service> $cr Stop the service
|
||||||
${colorgreen}restart <service> $cr Restart the service
|
${colorgreen}restart <service> $cr Restart the service
|
||||||
${colorgreen}reload <service> $cr Reload the service (send SIGHUP)
|
${colorgreen}reload <service> $cr Reload the service (send SIGHUP)
|
||||||
|
${colorgreen}logs <service> $cr Outputs the service's logfilenames and their access & error logs from /var/log/<serice>/
|
||||||
|
${colorgreen}alllogs <service> $cr The same like logs <service>
|
||||||
|
${colorgreen}errorlogs <service> $cr Outputs the service's logfilenames and their errorlogs from /var/log/<serice>/
|
||||||
|
|
||||||
|
|
||||||
${coloryellow}EXAMPLES:${colorgreen}
|
${coloryellow}EXAMPLES:${colorgreen}
|
||||||
${colorgreen}$progname $cr Show service status in /var/service
|
${colorgreen}$progname $cr Show service status in /var/service
|
||||||
@@ -492,6 +498,89 @@ do_enable_disable() {
|
|||||||
return "$ret"
|
return "$ret"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# show logs
|
||||||
|
do_show_logs() {
|
||||||
|
monitors_array=($(xrandr -q))
|
||||||
|
local cmd=$1
|
||||||
|
local svc
|
||||||
|
local ret=0
|
||||||
|
local file
|
||||||
|
shift
|
||||||
|
|
||||||
|
# Loop all arguments as services
|
||||||
|
msg "Running $progname $cmd $*"
|
||||||
|
|
||||||
|
for svc in "$@"; do
|
||||||
|
# Validate service name
|
||||||
|
if ! [[ $svc =~ $svc_re ]]; then
|
||||||
|
rmsg -1 "unexpected characters in name: '$svc'" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! [[ -d ${RSVDIR}${cmd} ]]; then
|
||||||
|
printf "\n%20s\n" "${colorgreen}The following log files found:"
|
||||||
|
local logs_files_array=($(ls /var/log/$cmd/*.*))
|
||||||
|
printf "\n$colorblue"
|
||||||
|
printf '%s\n' "${logs_files_array[@]}"
|
||||||
|
|
||||||
|
printf "\n$colormagenta"
|
||||||
|
read -n 1 -s -r -p "Press any key to continue"
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
printf "\n${colorcyan}Log files full output:\n"
|
||||||
|
printf "${coloryellow}\n"
|
||||||
|
printf "${coloryellow}${opt}"
|
||||||
|
|
||||||
|
tail -n 10 ${LOGDIR}${cmd}/*.* | more
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
||||||
|
return "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
|
# show error logs
|
||||||
|
do_show_err_logs() {
|
||||||
|
local cmd=$1
|
||||||
|
local svc
|
||||||
|
local ret=0
|
||||||
|
local file
|
||||||
|
shift
|
||||||
|
|
||||||
|
# Loop all arguments as services
|
||||||
|
msg "Running $progname $cmd $*"
|
||||||
|
|
||||||
|
for svc in "$@"; do
|
||||||
|
# Validate service name
|
||||||
|
if ! [[ $svc =~ $svc_re ]]; then
|
||||||
|
rmsg -1 "unexpected characters in name: '$svc'" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if ! [[ -d ${RSVDIR}${cmd} ]]; then
|
||||||
|
printf "\n%20s\n" "${colorred}The following error log files found:"
|
||||||
|
local logs_files_array=($(ls /var/log/$cmd/*error*.*))
|
||||||
|
printf "\n$colorblue"
|
||||||
|
printf '%s\n' "${logs_files_array[@]}"
|
||||||
|
|
||||||
|
printf "\n$colormagenta"
|
||||||
|
read -n 1 -s -r -p "Press any key to continue"
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
printf "\n${colorcyan}Log files full output:\n"
|
||||||
|
printf "${coloryellow}\n"
|
||||||
|
printf "${coloryellow}${opt}"
|
||||||
|
|
||||||
|
tail -n 10 ${LOGDIR}${cmd}/*error*.* | more
|
||||||
|
printf "\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmsg "$ret" "[$progname $cmd $*], exit code: $ret"
|
||||||
|
return "$ret"
|
||||||
|
}
|
||||||
|
|
||||||
# handle any other subcommand
|
# handle any other subcommand
|
||||||
do_sv_cmd() {
|
do_sv_cmd() {
|
||||||
if (($# < 2)); then
|
if (($# < 2)); then
|
||||||
@@ -550,6 +639,16 @@ case "$cmd" in
|
|||||||
enable|disable)
|
enable|disable)
|
||||||
do_enable_disable "$cmd" "$@"
|
do_enable_disable "$cmd" "$@"
|
||||||
;;
|
;;
|
||||||
|
logs)
|
||||||
|
do_show_logs "$@"
|
||||||
|
;;
|
||||||
|
alllogs)
|
||||||
|
do_show_logs "$@"
|
||||||
|
;;
|
||||||
|
errorlogs)
|
||||||
|
do_show_err_logs "$@"
|
||||||
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
if $tree; then
|
if $tree; then
|
||||||
rmsg -1 "-t can only be specified with 'status'"
|
rmsg -1 "-t can only be specified with 'status'"
|
||||||
|
Reference in New Issue
Block a user