-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·105 lines (85 loc) · 2.1 KB
/
install.sh
File metadata and controls
executable file
·105 lines (85 loc) · 2.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/bin/sh
set -e
BIN_NAME=openstack-docker-driver
DRIVER_URL="https://github.com/mvollman/openstack-docker-driver/releases/download/v0.2.0/openstack-docker-driver"
BIN_DIR="/usr/bin"
do_upstart() {
cat <<EOFUPSTART >/etc/init/${BIN_NAME}.conf
### START SCRIPT ###
# vim:set ft=upstart ts=2 et:
description "${BIN_NAME}"
author "Mike Vollman <mvollman@cas.org>"
start on (runlevel [2345] and started udev and started rsyslog and local-filesystems)
stop on (runlevel [016] and udev and rsyslog and local-filesystems)
expect daemon
respawn
respawn limit 10 5
# environment variables
env RUNBIN="${BIN_DIR}/${BIN_NAME}"
env NAME="$BIN_NAME"
env DAEMON_OPTS=''
# Run the daemon
script
set -a
[ -f /etc/default/$BIN_NAME ] && . /etc/default/$BIN_NAME
exec \$RUNBIN \$DAEMON_OPTS &
end script
### END SCRIPT ###
EOFUPSTART
}
do_systemd() {
cat <<EOFSYSD >/etc/systemd/system/${BIN_NAME}.service
[Unit]
Description=\"Openstack Docker Plugin daemon\"
Before=docker.service
Requires=${BIN_NAME}.service
[Service]
EnvironmentFile=-/etc/sysconfig/$BIN_NAME
TimeoutStartSec=0
ExecStart=$BIN_DIR/$BIN_NAME &
[Install]
WantedBy=docker.service
EOFSYSD
chmod 644 /etc/systemd/system/${BIN_NAME}.service
systemctl daemon-reload
systemctl enable $BIN_NAME
}
do_install() {
rm $BIN_DIR/$BIN_NAME 2>/dev/null|| true
curl -sSL -o $BIN_DIR/$BIN_NAME $DRIVER_URL
chmod +x $BIN_DIR/$BIN_NAME
osid=$(awk -F'=' '/^ID=/{print $2}' /etc/os-release)
osver=$(awk -F'=' '/^VERSION_ID=/{print $2}' /etc/os-release)
inittype='systemd'
config_path="/etc/sysconfig/$BIN_NAME"
if [[ "$osid" == 'ubuntu' ]] ; then
config_path="/etc/default/$BIN_NAME"
if [[ "$osver" == '"14.04"' ]]; then
inittype='upstart'
fi
fi
if [ ! -f $config_path ] ; then
cat << EOFENV > $config_path
# Driver Options
#MountPoint=/var/lib/$BIN_NAME
#FSType=ext4
SWARM_MODE=false
# Openstack Authentication
OS_REGION_NAME=
OS_USERNAME=
OS_PASSWORD=
OS_AUTH_URL=
OS_PROJECT_NAME=
OS_TENANT_NAME=
OS_TENANT_ID=
EOFENV
fi
case $inittype in
'upstart') do_upstart ;;
'systemd') do_systemd ;;
*) echo >&2 "Unknown OS version $osid $osver"
exit 1
;;
esac
}
do_install