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
Nurlan
eepm
Commits
6dd90af9
Commit
6dd90af9
authored
Aug 14, 2016
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serv: add anyservice support
parent
a3b42e85
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
78 additions
and
17 deletions
+78
-17
serv
bin/serv
+14
-0
serv-common
bin/serv-common
+3
-0
serv-disable
bin/serv-disable
+6
-2
serv-enable
bin/serv-enable
+7
-2
serv-list
bin/serv-list
+7
-2
serv-list_all
bin/serv-list_all
+7
-2
serv-print
bin/serv-print
+1
-0
serv-restart
bin/serv-restart
+6
-2
serv-start
bin/serv-start
+6
-2
serv-status
bin/serv-status
+14
-2
serv-stop
bin/serv-stop
+6
-2
serv-try_restart
bin/serv-try_restart
+1
-1
No files found.
bin/serv
View file @
6dd90af9
...
...
@@ -98,8 +98,22 @@ is_active_systemd && CMD="systemd"
SERVICETYPE
=
$CMD
ANYSERVICE
=
$(
which anyservice 2>/dev/null
>
/dev/null
)
ANYSERVDIR
=
"/etc/systemd-lite"
ANYSYSDDIR
=
"/lib/systemd/system"
}
is_anyservice
()
{
local
SERVICE
=
"
$1
"
# not, if we have no anyservice at all
[
-n
"
$ANYSERVICE
"
]
||
return
1
# not, if there is regular service with the name
[
-d
"
$INITDIR
/
$SERVICE
"
]
&&
return
1
# yes, if the service is anyservice driven
[
-r
"
$ANYSERVDIR
/
$SERVICE
.service"
]
}
phelp
()
...
...
bin/serv-common
View file @
6dd90af9
...
...
@@ -24,6 +24,9 @@ serv_common()
shift
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
fatal
"Have no idea how to call anyservice service with args"
fi
sudocmd service
$SERVICE
"
$@
"
;;
service-initd|service-update
)
...
...
bin/serv-disable
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -28,6 +28,10 @@ serv_disable()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
off
return
fi
sudocmd chkconfig
$1
off
;;
service-initd|service-update
)
...
...
bin/serv-enable
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -28,6 +28,11 @@ serv_enable()
case
$SERVICETYPE
in
service-chkconfig
)
# can't use is_anyservice here
if
[
!
-d
"
$INITDIR
/
$SERVICE
"
]
&&
[
-n
"
$ANYSERVICE
"
]
&&
[
-r
"
$ANYSYSDDIR
/
$SERVICE
.service"
]
;
then
sudocmd anyservice
$SERVICE
on
return
fi
sudocmd chkconfig
--add
$1
||
return
sudocmd chkconfig
$1
on
;;
...
...
bin/serv-list
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -38,6 +38,11 @@ serv_list()
for
i
in
$(
serv_list_all
)
;
do
is_service_running
$i
>
/dev/null
&&
echo
$i
done
# TODO: только запущенные
if
[
-n
"
$ANYSERVICE
"
]
;
then
sudocmd anyservice list
return
fi
;;
esac
}
bin/serv-list_all
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
,2016
Etersoft
# Copyright (C) 2012
,2016
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
...
...
@@ -24,6 +24,11 @@ serv_list_all()
service-chkconfig|service-upstart
)
# service --status-all for Ubuntu/Fedora
sudocmd chkconfig
--list
|
cut
-f1
if
[
-n
"
$ANYSERVICE
"
]
;
then
sudocmd anyservice list
return
fi
;;
service-initd|service-update
)
sudocmd
ls
$INITDIR
/ |
grep
-v
README
...
...
bin/serv-print
View file @
6dd90af9
...
...
@@ -20,4 +20,5 @@
serv_print
()
{
echo
"Detected init system:
$SERVICETYPE
"
[
-n
"
$ANYSERVICE
"
]
&&
echo
"anyservice is detected too"
}
bin/serv-restart
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -27,6 +27,10 @@ serv_restart()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
restart
return
fi
sudocmd service
$SERVICE
restart
"
$@
"
;;
service-initd|service-update
)
...
...
bin/serv-start
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -25,6 +25,10 @@ serv_start()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
start
return
fi
sudocmd service
$SERVICE
start
"
$@
"
;;
service-initd|service-update
)
...
...
bin/serv-status
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012, 2013 Etersoft
# Copyright (C) 2012, 2013 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012, 2013
, 2016
Etersoft
# Copyright (C) 2012, 2013
, 2016
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,6 +22,10 @@ is_service_running()
{
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
$SUDO
anyservice
$1
status
>
/dev/null
return
fi
$SUDO
service
$1
status
>
/dev/null
;;
service-initd|service-update
)
...
...
@@ -41,6 +45,10 @@ is_service_autostart()
{
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
# if is registered, assume it is autostarted
return
0
fi
# FIXME: check for current runlevel
LANG
=
C
$SUDO
chkconfig
$1
--list
|
grep
-q
"[35]:on"
;;
...
...
@@ -65,6 +73,10 @@ serv_status()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
status
return
fi
sudocmd service
$SERVICE
status
"
$@
"
;;
service-update
)
...
...
bin/serv-stop
View file @
6dd90af9
#!/bin/sh
#
# Copyright (C) 2012 Etersoft
# Copyright (C) 2012 Vitaly Lipatov <lav@etersoft.ru>
# Copyright (C) 2012
, 2016
Etersoft
# Copyright (C) 2012
, 2016
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
...
...
@@ -25,6 +25,10 @@ serv_stop()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
if
is_anyservice
$SERVICE
;
then
sudocmd anyservice
$SERVICE
stop
return
fi
sudocmd service
$SERVICE
stop
"
$@
"
;;
service-initd|service-update
)
...
...
bin/serv-try_restart
View file @
6dd90af9
...
...
@@ -28,7 +28,7 @@ serv_try_restart()
case
$SERVICETYPE
in
service-chkconfig|service-upstart
)
is_service_running
$SERVICE
||
return
0
sudocmd service
$SERVICE
restart
"
$@
"
docmd serv
$SERVICE
restart
"
$@
"
;;
service-initd|service-update
)
is_service_running
$SERVICE
||
return
0
...
...
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