-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlabel-install
69 lines (60 loc) · 1.74 KB
/
label-install
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
#!/bin/bash
create_command_bin() {
SCRIPT=$1
if [ ! -e ${TARGET_BIN}/${SCRIPT} ]; then
cd ${TARGET_BIN}; ln -s ansible-wrapper.sh ${SCRIPT}
else
echo "${TARGET_BIN}/${SCRIPT} already exist, will not update it"
fi
}
if [ ! -e ${TARGET_BIN}/${SCRIPT} ]; then
echo "Failed to create ${TARGET_BIN}/${SCRIPT}"
exit 1
fi
# Commands to create
COMMANDS="ansible \
ansible-config \
ansible-console \
ansible-galaxy \
ansible-playbook \
ansible-vault \
ansible-community \
ansible-connection \
ansible-doc \
ansible-inventory \
ansible-test \
ansible-lint \
ansible-pull"
# determime target root directory
# either /usr/local/bin or current user ~/bin
if [ -d /host/usr/local/bin ]; then
TARGET_ROOT=/host/usr/local
IMAGE_CONF_DIR=etc/default
IMAGE_CONF_FILE=ansible-container
elif [ -d /host/bin ] ; then
TARGET_ROOT=/host
IMAGE_CONF_DIR=.config/ansible-container
IMAGE_CONF_FILE=image
else
echo "could not determine copy target"
exit 1
fi
TARGET_BIN=${TARGET_ROOT}/bin
TARGET_SHARE=${TARGET_ROOT}/share/ansible-container
TARGET_CONF_DIR=${TARGET_ROOT}/${IMAGE_CONF_DIR}
cp -v /container/ansible-wrapper.sh ${TARGET_BIN}/ansible-wrapper.sh
for COMMAND in ${COMMANDS}; do
create_command_bin ${COMMAND}
done
# Create container share area under /usr/local/share if it doesn't exist
if [ ! -d ${TARGET_SHARE} ]; then
mkdir -p ${TARGET_SHARE}
fi
# Copy examples to container share area, overwriting any previous content.
cp -av /container/examples ${TARGET_SHARE}/
# Save container image used to install the container to appropriate conf
# file
if [ ! -d ${TARGET_CONF_DIR} ]; then
mkdir -p ${TARGET_CONF_DIR}
fi
echo "IMAGE=${IMAGE}" > ${TARGET_CONF_DIR}/${IMAGE_CONF_FILE}