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
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
15 deletions
+40
-15
serv
bin/serv
+3
-0
serv-list
bin/serv-list
+8
-4
serv-list_all
bin/serv-list_all
+24
-4
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()
...
@@ -248,6 +248,9 @@ check_option()
--verbose
)
# HELPOPT: verbose mode
--verbose
)
# HELPOPT: verbose mode
verbose
=
1
verbose
=
1
;;
;;
--short
)
# HELPOPT: short mode
short
=
1
;;
--show-command-only
)
# HELPOPT: show command only, do not any action
--show-command-only
)
# HELPOPT: show command only, do not any action
show_command_only
=
1
show_command_only
=
1
;;
;;
...
...
bin/serv-list
View file @
5d473d09
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2012, 2016 Etersoft
# Copyright (C) 2012, 2016
, 2021
Etersoft
# Copyright (C) 2012, 2016 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2016
, 2021
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# 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
# it under the terms of the GNU Affero General Public License as published by
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
# List running services
# List running services
serv_list
()
serv_list
()
{
{
info
"Running services:"
[
-n
"
$short
"
]
||
info
"Running services:"
case
$SERVICETYPE
in
case
$SERVICETYPE
in
# service-chkconfig)
# service-chkconfig)
# ;;
# ;;
...
@@ -31,7 +31,11 @@ serv_list()
...
@@ -31,7 +31,11 @@ serv_list()
sudocmd service
--status-all
sudocmd service
--status-all
;;
;;
systemd
)
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
)
openrc
)
sudocmd rc-status
sudocmd rc-status
...
...
bin/serv-list_all
View file @
5d473d09
#!/bin/sh
#!/bin/sh
#
#
# Copyright (C) 2012,
2016
Etersoft
# Copyright (C) 2012,
2016, 2021
Etersoft
# Copyright (C) 2012,
2016
Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012,
2016, 2021
Vitaly Lipatov <lav@etersoft.ru>
#
#
# This program is free software: you can redistribute it and/or modify
# 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
# it under the terms of the GNU Affero General Public License as published by
...
@@ -22,22 +22,42 @@ serv_list_all()
...
@@ -22,22 +22,42 @@ serv_list_all()
{
{
case
$SERVICETYPE
in
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
service-chkconfig|service-upstart
)
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
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
|
grep
-v
"^$"
|
grep
-v
"xinetd:$"
sudocmd chkconfig
--list
|
cut
-f1
|
grep
-v
"^$"
|
grep
-v
"xinetd:$"
fi
if
[
-n
"
$ANYSERVICE
"
]
;
then
if
[
-n
"
$ANYSERVICE
"
]
;
then
if
[
-n
"
$short
"
]
;
then
sudocmd anyservice
--quiet
list |
cut
-f
1
-d
" "
else
sudocmd anyservice
--quiet
list
sudocmd anyservice
--quiet
list
fi
return
return
fi
fi
;;
;;
service-initd|service-update
)
service-initd|service-update
)
if
[
-n
"
$short
"
]
;
then
sudocmd
ls
$INITDIR
/ |
grep
-v
README |
cut
-f
1
-d
" "
else
sudocmd
ls
$INITDIR
/ |
grep
-v
README
sudocmd
ls
$INITDIR
/ |
grep
-v
README
fi
;;
;;
systemd
)
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
)
openrc
)
if
[
-n
"
$short
"
]
;
then
sudocmd rc-service
-l
|
cut
-f
1
-d
" "
else
sudocmd rc-service
-l
sudocmd rc-service
-l
fi
;;
;;
*
)
*
)
fatal
"Have no suitable command for
$SERVICETYPE
"
fatal
"Have no suitable command for
$SERVICETYPE
"
...
...
bin/serv-list_failed
View file @
5d473d09
...
@@ -33,12 +33,11 @@ serv_list_failed()
...
@@ -33,12 +33,11 @@ serv_list_failed()
*
)
*
)
load_helper serv-list_startup
load_helper serv-list_startup
load_helper serv-status
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
is_service_running
>
/dev/null
$i
&&
continue
echo
;
echo
$i
echo
;
echo
$i
serv_status
$i
serv_status
$i
done
done
;;
;;
esac
esac
}
}
bin/serv-list_startup
View file @
5d473d09
...
@@ -32,15 +32,14 @@ serv_list_startup()
...
@@ -32,15 +32,14 @@ serv_list_startup()
systemd
)
systemd
)
#sudocmd systemctl list-unit-files
#sudocmd systemctl list-unit-files
# TODO: native command? implement --short for list (only names)
# TODO: native command? implement --short for list (only names)
for
i
in
$(
s
erv_list_all |
cut
-f
1
-d
" "
|
grep
"
\.
service$"
)
;
do
for
i
in
$(
s
hort
=
1 serv_list_all
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
is_service_autostart
>
/dev/null
2>/dev/null
$i
&&
echo
$i
done
done
;;
;;
*
)
*
)
for
i
in
$(
s
erv_list_all |
cut
-f
1
-d
" "
)
;
do
for
i
in
$(
s
hort
=
1 serv_list_all
)
;
do
is_service_autostart
>
/dev/null
$i
&&
echo
$i
is_service_autostart
>
/dev/null
2>/dev/null
$i
&&
echo
$i
done
done
;;
;;
esac
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