Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
eepm
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
eepm
Commits
5d473d09
Commit
5d473d09
authored
Sep 01, 2021
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serv: add --short support for lists
parent
6df9738b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
20 deletions
+45
-20
serv
bin/serv
+3
-0
serv-list
bin/serv-list
+8
-4
serv-list_all
bin/serv-list_all
+29
-9
serv-list_failed
bin/serv-list_failed
+1
-2
serv-list_startup
bin/serv-list_startup
+4
-5
No files found.
bin/serv
View file @
5d473d09
...
...
@@ -248,6 +248,9 @@ check_option()
--verbose
)
# HELPOPT: verbose mode
verbose
=
1
;;
--short
)
# HELPOPT: short mode
short
=
1
;;
--show-command-only
)
# HELPOPT: show command only, do not any action
show_command_only
=
1
;;
...
...
bin/serv-list
View file @
5d473d09
#!/bin/sh
#
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016
, 2021
Etersoft
# Copyright (C) 2012, 2016
, 2021
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -20,7 +20,7 @@
# List running services
serv_list
()
{
info
"Running services:"
[
-n
"
$short
"
]
||
info
"Running services:"
case
$SERVICETYPE
in
# service-chkconfig)
# ;;
...
...
@@ -31,7 +31,11 @@ serv_list()
sudocmd service
--status-all
;;
systemd
)
sudocmd systemctl list-units
$@
if
[
-n
"
$short
"
]
;
then
docmd systemctl list-units
--type
=
service
"
$@
"
|
grep
'\.service'
|
sed
-e
's|\.service.*||'
-e
's|^ *||'
else
docmd systemctl list-units
--type
=
service
"
$@
"
fi
;;
openrc
)
sudocmd rc-status
...
...
bin/serv-list_all
View file @
5d473d09
#!/bin/sh
#
# Copyright (C) 2012,
2016
Etersoft
# Copyright (C) 2012,
2016
Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,
2016, 2021
Etersoft
# Copyright (C) 2012,
2016, 2021
Vitaly Lipatov <lav@etersoft.ru>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
...
...
@@ -22,22 +22,42 @@ serv_list_all()
{
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
|
grep
-v
"^$"
|
grep
-v
"xinetd:$"
if
[
-n
"
$short
"
]
;
then
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
|
grep
-v
"^$"
|
grep
-v
"xinetd:$"
|
cut
-f
1
-d
" "
else
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
|
grep
-v
"^$"
|
grep
-v
"xinetd:$"
fi
if
[
-n
"
$ANYSERVICE
"
]
;
then
sudocmd anyservice
--quiet
list
if
[
-n
"
$short
"
]
;
then
sudocmd anyservice
--quiet
list |
cut
-f
1
-d
" "
else
sudocmd anyservice
--quiet
list
fi
return
fi
;;
service-initd|service-update
)
sudocmd
ls
$INITDIR
/ |
grep
-v
README
if
[
-n
"
$short
"
]
;
then
sudocmd
ls
$INITDIR
/ |
grep
-v
README |
cut
-f
1
-d
" "
else
sudocmd
ls
$INITDIR
/ |
grep
-v
README
fi
;;
systemd
)
sudocmd systemctl list-unit-files
$@
if
[
-n
"
$short
"
]
;
then
docmd systemctl list-unit-files
--type
=
service
"
$@
"
|
sed
-e
's|\.service.*||'
|
grep
-v
'unit files listed'
|
grep
-v
'^$'
else
docmd systemctl list-unit-files
--type
=
service
"
$@
"
fi
;;
openrc
)
sudocmd rc-service
-l
if
[
-n
"
$short
"
]
;
then
sudocmd rc-service
-l
|
cut
-f
1
-d
" "
else
sudocmd rc-service
-l
fi
;;
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
...
...
bin/serv-list_failed
View file @
5d473d09
...
...
@@ -33,12 +33,11 @@ serv_list_failed()
*
)
load_helper serv-list_startup
load_helper serv-status
for
i
in
$(
s
erv_list_startup |
cut
-f
1
-d
" "
)
;
do
for
i
in
$(
s
hort
=
1 serv_list_startup
)
;
do
is_service_running
>
/dev/null
$i
&&
continue
echo
;
echo
$i
serv_status
$i
done
;;
esac
}
bin/serv-list_startup
View file @
5d473d09
...
...
@@ -32,15 +32,14 @@ serv_list_startup()
systemd
)
#sudocmd systemctl list-unit-files
# TODO: native command? implement --short for list (only names)
for
i
in
$(
s
erv_list_all |
cut
-f
1
-d
" "
|
grep
"
\.
service$"
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
for
i
in
$(
s
hort
=
1 serv_list_all
)
;
do
is_service_autostart
>
/dev/null
2>/dev/null
$i
&&
echo
$i
done
;;
*
)
for
i
in
$(
s
erv_list_all |
cut
-f
1
-d
" "
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
for
i
in
$(
s
hort
=
1 serv_list_all
)
;
do
is_service_autostart
>
/dev/null
2>/dev/null
$i
&&
echo
$i
done
;;
esac
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment