Add initial svc-map support
This patch incorporates the svc-map patch[1] into other elements by integrating svc-map into the os-svc-install element. This patch adds the -a option to select svc-map instead of the default of map-services. The -a option enables a phased transition from map-services to svc-map usage throughout the rest of the elements. [1] Id11433ea342aace71a358936a7ca3151ec11d506 Change-Id: I382631746e458f2f8603a7dcf5221a21f4b53255
This commit is contained in:
parent
4dbfc3a032
commit
49dbaae6df
|
@ -10,6 +10,7 @@ usage() {
|
|||
echo "environment as well. Command line arguments will override"
|
||||
echo "environment variables."
|
||||
echo ""
|
||||
echo " -a Use alternate svc-map instead of map-services"
|
||||
echo " -h Show help and exit"
|
||||
echo " -p Print the job file instead of writing to disk"
|
||||
echo " -d [NAME] Specify the name of the runtime directory, which will be"
|
||||
|
@ -34,6 +35,7 @@ ENV=${ENV:-""}
|
|||
CREATE_DIR_NAME=${CREATE_DIR_NAME:-""}
|
||||
# The default helps avoid race with daemon listening. http://pad.lv/1179766
|
||||
POSTSTART=${POSTSTART:-$DEFAULT_POSTSTART}
|
||||
MAPPING_COMMAND=map-services
|
||||
|
||||
print_only() {
|
||||
cat
|
||||
|
@ -51,7 +53,7 @@ OUTPUT=print_to_file
|
|||
APPEND=append_to_file
|
||||
|
||||
nshift=0
|
||||
while getopts "phd:s:n:i:u:c:e:" opt; do
|
||||
while getopts "aphd:s:n:i:u:c:e:" opt; do
|
||||
case "$opt" in
|
||||
n) SERVICENAME=$OPTARG;;
|
||||
i) INSTALLDIR=$OPTARG;;
|
||||
|
@ -59,6 +61,7 @@ while getopts "phd:s:n:i:u:c:e:" opt; do
|
|||
c) RUNCMD=$OPTARG;;
|
||||
s) POSTSTART=$OPTARG;;
|
||||
e) ENV=$OPTARG;;
|
||||
a) MAPPING_COMMAND=svc-map;;
|
||||
p) OUTPUT=print_only; APPEND=print_only;;
|
||||
d) CREATE_DIR_NAME=$OPTARG;;
|
||||
h) usage; exit 0;;
|
||||
|
@ -172,7 +175,7 @@ EOF
|
|||
}
|
||||
|
||||
function install_create_dir_systemd {
|
||||
local name=$(map-services $1)
|
||||
local name="$($MAPPING_COMMAND "$1")"
|
||||
local user=$2
|
||||
local dirname=${3:-$user}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ set -eu
|
|||
usage() {
|
||||
echo "Usage: os-svc-enable -n SERVICENAME"
|
||||
echo ""
|
||||
echo " -a Use alternate svc-map instead of map-services"
|
||||
echo " -h Show help and exit"
|
||||
echo " -n SERVICENAME Name of job/service file."
|
||||
echo ""
|
||||
|
@ -27,12 +28,14 @@ usage() {
|
|||
}
|
||||
|
||||
SERVICENAME=${SERVICENAME:-""}
|
||||
MAPPING_COMMAND=map-services
|
||||
|
||||
nshift=0
|
||||
while getopts "hn:" opt; do
|
||||
while getopts "ahn:" opt; do
|
||||
case "$opt" in
|
||||
n) SERVICENAME=$OPTARG;;
|
||||
h) usage 0;;
|
||||
a) MAPPING_COMMAND=svc-map;;
|
||||
\?) usage 1;;
|
||||
:) usage 1;;
|
||||
esac
|
||||
|
@ -44,24 +47,24 @@ if [ -z "$SERVICENAME" ] ; then
|
|||
fi
|
||||
|
||||
function enable_upstart_service() {
|
||||
local name=$1
|
||||
os-svc-enable-upstart $name enable
|
||||
local name="$1"
|
||||
os-svc-enable-upstart "$name" enable
|
||||
}
|
||||
|
||||
function enable_systemd_service() {
|
||||
local name=$1
|
||||
local service_name=$(map-services $name)
|
||||
systemctl enable $service_name.service
|
||||
local name="$1"
|
||||
local service_name="$($MAPPING_COMMAND "$name")"
|
||||
systemctl enable "$service_name.service"
|
||||
# Also enable the create-dir service if it exists
|
||||
if [ -f /usr/lib/systemd/system/$service_name-create-dir.service ]; then
|
||||
systemctl enable $service_name-create-dir.service
|
||||
if [ -f "/usr/lib/systemd/system/$service_name-create-dir.service" ]; then
|
||||
systemctl enable "$service_name-create-dir.service"
|
||||
fi
|
||||
}
|
||||
|
||||
# TODO: SysV init fallback support
|
||||
DIB_INIT_SYSTEM=$(dib-init-system)
|
||||
if [ "$DIB_INIT_SYSTEM" = "upstart" ]; then
|
||||
enable_upstart_service $SERVICENAME
|
||||
enable_upstart_service "$SERVICENAME"
|
||||
elif [ "$DIB_INIT_SYSTEM" = "systemd" ]; then
|
||||
enable_systemd_service $SERVICENAME
|
||||
enable_systemd_service "$SERVICENAME"
|
||||
fi
|
||||
|
|
|
@ -20,6 +20,7 @@ set -eu
|
|||
usage() {
|
||||
echo "Usage: os-svc-restart -n SERVICENAME"
|
||||
echo ""
|
||||
echo " -a Use alternate svc-map instead of map-services"
|
||||
echo " -h Show help and exit"
|
||||
echo " -n SERVICENAME Name of job/service file."
|
||||
echo ""
|
||||
|
@ -27,12 +28,14 @@ usage() {
|
|||
}
|
||||
|
||||
SERVICENAME=${SERVICENAME:-""}
|
||||
MAPPING_COMMAND=map-services
|
||||
|
||||
nshift=0
|
||||
while getopts "hn:" opt; do
|
||||
case "$opt" in
|
||||
n) SERVICENAME=$OPTARG;;
|
||||
h) usage 0;;
|
||||
a) MAPPING_COMMAND=svc-map;;
|
||||
\?) usage 0;;
|
||||
:) usage 1;;
|
||||
esac
|
||||
|
@ -44,19 +47,19 @@ if [ -z "$SERVICENAME" ] ; then
|
|||
fi
|
||||
|
||||
function restart_upstart_service {
|
||||
local name=$1
|
||||
service $name restart
|
||||
local name="$1"
|
||||
service "$name" restart
|
||||
}
|
||||
|
||||
function restart_systemd_service {
|
||||
local name=$1
|
||||
systemctl restart $(map-services $name).service
|
||||
local name="$1"
|
||||
systemctl restart "$($MAPPING_COMMAND "$name").service"
|
||||
}
|
||||
|
||||
# TODO: SysV init fallback support
|
||||
DIB_INIT_SYSTEM=$(dib-init-system)
|
||||
if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
|
||||
restart_upstart_service $SERVICENAME
|
||||
restart_upstart_service "$SERVICENAME"
|
||||
elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
|
||||
restart_systemd_service $SERVICENAME
|
||||
restart_systemd_service "$SERVICENAME"
|
||||
fi
|
||||
|
|
|
@ -2,3 +2,4 @@ mysql-dev
|
|||
pip-and-virtualenv
|
||||
pip-manifest
|
||||
selinux
|
||||
svc-map
|
||||
|
|
Loading…
Reference in New Issue