summaryrefslogtreecommitdiff
path: root/elements/os-svc-install
diff options
context:
space:
mode:
authorRyan Brady <rbrady@redhat.com>2014-09-15 16:17:03 -0400
committerRyan Brady <rbrady@redhat.com>2014-10-02 10:35:54 -0400
commit49dbaae6df0ca9104a5feba38de956668b8088bc (patch)
tree25d82ec424eb31c24179df0944329be57b0ce5ce /elements/os-svc-install
parent4dbfc3a032eade978ba31b164f24e9b64945b942 (diff)
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
Notes
Notes (review): Verified+2: Jenkins Code-Review+2: Ladislav Smola <lsmola@redhat.com> Code-Review+2: Marios Andreou <marios@redhat.com> Workflow+1: Marios Andreou <marios@redhat.com> Submitted-by: Jenkins Submitted-at: Mon, 06 Oct 2014 07:46:43 +0000 Reviewed-on: https://review.openstack.org/104196 Project: openstack/tripleo-image-elements Branch: refs/heads/master
Diffstat (limited to 'elements/os-svc-install')
-rwxr-xr-xelements/os-svc-install/bin/os-svc-daemon7
-rwxr-xr-xelements/os-svc-install/bin/os-svc-enable23
-rwxr-xr-xelements/os-svc-install/bin/os-svc-restart15
-rw-r--r--elements/os-svc-install/element-deps1
4 files changed, 28 insertions, 18 deletions
diff --git a/elements/os-svc-install/bin/os-svc-daemon b/elements/os-svc-install/bin/os-svc-daemon
index d142e1d..a0b2e43 100755
--- a/elements/os-svc-install/bin/os-svc-daemon
+++ b/elements/os-svc-install/bin/os-svc-daemon
@@ -10,6 +10,7 @@ usage() {
10 echo "environment as well. Command line arguments will override" 10 echo "environment as well. Command line arguments will override"
11 echo "environment variables." 11 echo "environment variables."
12 echo "" 12 echo ""
13 echo " -a Use alternate svc-map instead of map-services"
13 echo " -h Show help and exit" 14 echo " -h Show help and exit"
14 echo " -p Print the job file instead of writing to disk" 15 echo " -p Print the job file instead of writing to disk"
15 echo " -d [NAME] Specify the name of the runtime directory, which will be" 16 echo " -d [NAME] Specify the name of the runtime directory, which will be"
@@ -34,6 +35,7 @@ ENV=${ENV:-""}
34CREATE_DIR_NAME=${CREATE_DIR_NAME:-""} 35CREATE_DIR_NAME=${CREATE_DIR_NAME:-""}
35# The default helps avoid race with daemon listening. http://pad.lv/1179766 36# The default helps avoid race with daemon listening. http://pad.lv/1179766
36POSTSTART=${POSTSTART:-$DEFAULT_POSTSTART} 37POSTSTART=${POSTSTART:-$DEFAULT_POSTSTART}
38MAPPING_COMMAND=map-services
37 39
38print_only() { 40print_only() {
39 cat 41 cat
@@ -51,7 +53,7 @@ OUTPUT=print_to_file
51APPEND=append_to_file 53APPEND=append_to_file
52 54
53nshift=0 55nshift=0
54while getopts "phd:s:n:i:u:c:e:" opt; do 56while getopts "aphd:s:n:i:u:c:e:" opt; do
55 case "$opt" in 57 case "$opt" in
56 n) SERVICENAME=$OPTARG;; 58 n) SERVICENAME=$OPTARG;;
57 i) INSTALLDIR=$OPTARG;; 59 i) INSTALLDIR=$OPTARG;;
@@ -59,6 +61,7 @@ while getopts "phd:s:n:i:u:c:e:" opt; do
59 c) RUNCMD=$OPTARG;; 61 c) RUNCMD=$OPTARG;;
60 s) POSTSTART=$OPTARG;; 62 s) POSTSTART=$OPTARG;;
61 e) ENV=$OPTARG;; 63 e) ENV=$OPTARG;;
64 a) MAPPING_COMMAND=svc-map;;
62 p) OUTPUT=print_only; APPEND=print_only;; 65 p) OUTPUT=print_only; APPEND=print_only;;
63 d) CREATE_DIR_NAME=$OPTARG;; 66 d) CREATE_DIR_NAME=$OPTARG;;
64 h) usage; exit 0;; 67 h) usage; exit 0;;
@@ -172,7 +175,7 @@ EOF
172} 175}
173 176
174function install_create_dir_systemd { 177function install_create_dir_systemd {
175 local name=$(map-services $1) 178 local name="$($MAPPING_COMMAND "$1")"
176 local user=$2 179 local user=$2
177 local dirname=${3:-$user} 180 local dirname=${3:-$user}
178 181
diff --git a/elements/os-svc-install/bin/os-svc-enable b/elements/os-svc-install/bin/os-svc-enable
index 0ae172a..e80f614 100755
--- a/elements/os-svc-install/bin/os-svc-enable
+++ b/elements/os-svc-install/bin/os-svc-enable
@@ -20,6 +20,7 @@ set -eu
20usage() { 20usage() {
21 echo "Usage: os-svc-enable -n SERVICENAME" 21 echo "Usage: os-svc-enable -n SERVICENAME"
22 echo "" 22 echo ""
23 echo " -a Use alternate svc-map instead of map-services"
23 echo " -h Show help and exit" 24 echo " -h Show help and exit"
24 echo " -n SERVICENAME Name of job/service file." 25 echo " -n SERVICENAME Name of job/service file."
25 echo "" 26 echo ""
@@ -27,12 +28,14 @@ usage() {
27} 28}
28 29
29SERVICENAME=${SERVICENAME:-""} 30SERVICENAME=${SERVICENAME:-""}
31MAPPING_COMMAND=map-services
30 32
31nshift=0 33nshift=0
32while getopts "hn:" opt; do 34while getopts "ahn:" opt; do
33 case "$opt" in 35 case "$opt" in
34 n) SERVICENAME=$OPTARG;; 36 n) SERVICENAME=$OPTARG;;
35 h) usage 0;; 37 h) usage 0;;
38 a) MAPPING_COMMAND=svc-map;;
36 \?) usage 1;; 39 \?) usage 1;;
37 :) usage 1;; 40 :) usage 1;;
38 esac 41 esac
@@ -44,24 +47,24 @@ if [ -z "$SERVICENAME" ] ; then
44fi 47fi
45 48
46function enable_upstart_service() { 49function enable_upstart_service() {
47 local name=$1 50 local name="$1"
48 os-svc-enable-upstart $name enable 51 os-svc-enable-upstart "$name" enable
49} 52}
50 53
51function enable_systemd_service() { 54function enable_systemd_service() {
52 local name=$1 55 local name="$1"
53 local service_name=$(map-services $name) 56 local service_name="$($MAPPING_COMMAND "$name")"
54 systemctl enable $service_name.service 57 systemctl enable "$service_name.service"
55 # Also enable the create-dir service if it exists 58 # Also enable the create-dir service if it exists
56 if [ -f /usr/lib/systemd/system/$service_name-create-dir.service ]; then 59 if [ -f "/usr/lib/systemd/system/$service_name-create-dir.service" ]; then
57 systemctl enable $service_name-create-dir.service 60 systemctl enable "$service_name-create-dir.service"
58 fi 61 fi
59} 62}
60 63
61# TODO: SysV init fallback support 64# TODO: SysV init fallback support
62DIB_INIT_SYSTEM=$(dib-init-system) 65DIB_INIT_SYSTEM=$(dib-init-system)
63if [ "$DIB_INIT_SYSTEM" = "upstart" ]; then 66if [ "$DIB_INIT_SYSTEM" = "upstart" ]; then
64 enable_upstart_service $SERVICENAME 67 enable_upstart_service "$SERVICENAME"
65elif [ "$DIB_INIT_SYSTEM" = "systemd" ]; then 68elif [ "$DIB_INIT_SYSTEM" = "systemd" ]; then
66 enable_systemd_service $SERVICENAME 69 enable_systemd_service "$SERVICENAME"
67fi 70fi
diff --git a/elements/os-svc-install/bin/os-svc-restart b/elements/os-svc-install/bin/os-svc-restart
index 5c6e4c9..a9ccabe 100755
--- a/elements/os-svc-install/bin/os-svc-restart
+++ b/elements/os-svc-install/bin/os-svc-restart
@@ -20,6 +20,7 @@ set -eu
20usage() { 20usage() {
21 echo "Usage: os-svc-restart -n SERVICENAME" 21 echo "Usage: os-svc-restart -n SERVICENAME"
22 echo "" 22 echo ""
23 echo " -a Use alternate svc-map instead of map-services"
23 echo " -h Show help and exit" 24 echo " -h Show help and exit"
24 echo " -n SERVICENAME Name of job/service file." 25 echo " -n SERVICENAME Name of job/service file."
25 echo "" 26 echo ""
@@ -27,12 +28,14 @@ usage() {
27} 28}
28 29
29SERVICENAME=${SERVICENAME:-""} 30SERVICENAME=${SERVICENAME:-""}
31MAPPING_COMMAND=map-services
30 32
31nshift=0 33nshift=0
32while getopts "hn:" opt; do 34while getopts "hn:" opt; do
33 case "$opt" in 35 case "$opt" in
34 n) SERVICENAME=$OPTARG;; 36 n) SERVICENAME=$OPTARG;;
35 h) usage 0;; 37 h) usage 0;;
38 a) MAPPING_COMMAND=svc-map;;
36 \?) usage 0;; 39 \?) usage 0;;
37 :) usage 1;; 40 :) usage 1;;
38 esac 41 esac
@@ -44,19 +47,19 @@ if [ -z "$SERVICENAME" ] ; then
44fi 47fi
45 48
46function restart_upstart_service { 49function restart_upstart_service {
47 local name=$1 50 local name="$1"
48 service $name restart 51 service "$name" restart
49} 52}
50 53
51function restart_systemd_service { 54function restart_systemd_service {
52 local name=$1 55 local name="$1"
53 systemctl restart $(map-services $name).service 56 systemctl restart "$($MAPPING_COMMAND "$name").service"
54} 57}
55 58
56# TODO: SysV init fallback support 59# TODO: SysV init fallback support
57DIB_INIT_SYSTEM=$(dib-init-system) 60DIB_INIT_SYSTEM=$(dib-init-system)
58if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then 61if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
59 restart_upstart_service $SERVICENAME 62 restart_upstart_service "$SERVICENAME"
60elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then 63elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
61 restart_systemd_service $SERVICENAME 64 restart_systemd_service "$SERVICENAME"
62fi 65fi
diff --git a/elements/os-svc-install/element-deps b/elements/os-svc-install/element-deps
index 8741d81..0dc4c86 100644
--- a/elements/os-svc-install/element-deps
+++ b/elements/os-svc-install/element-deps
@@ -2,3 +2,4 @@ mysql-dev
2pip-and-virtualenv 2pip-and-virtualenv
3pip-manifest 3pip-manifest
4selinux 4selinux
5svc-map