-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpost-import
executable file
·53 lines (47 loc) · 1.49 KB
/
post-import
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
#!/bin/bash
set -eu -o pipefail
function help () {
echo "$(basename ${0}): Install this instance of forklift"
echo
echo "Usage: $(basename ${0})"
echo
}
SELF_DIR=$(cd $(dirname ${0}) && pwd -P)
SELF=${SELF_DIR}/$(basename ${0})
INSTALL_DIR=$(cd ${SELF_DIR}/.. && pwd -P)
. ${INSTALL_DIR}/builtin/common/source.bash
if [ -x ${FLBIN_DIR}/forklift ]; then
echo "Found existing forklift install, checking version"
VER_EXIST=$(${FLBIN_DIR}/forklift version)
VER_MINE=$(${INSTALL_DIR}/forklift version)
if [ "${VER_EXIST}" == "development" ] && [ "${VER_MINE}" == "development" ]; then
echo "Installing a development 'upgrade'"
INSTALL_FLAG=1
elif ${INSTALL_DIR}/builtin/common/version isnewer ${VER_EXIST} ${VER_MINE}; then
echo "Found ${VER_EXIST}, will install ${VER_MINE} as an upgrade"
INSTALL_FLAG=1
else
echo "Found ${VER_EXIST}, will not install ${VER_MINE} over it"
INSTALL_FLAG=0
fi
else
INSTALL_FLAG=1
fi
if [ "${INSTALL_FLAG}" -ne 0 ]; then
echo "Installing forklift"
create_flbin_dir
cat > ${FLBIN_DIR}/forklift <<EOF
#!/bin/bash
${INSTALL_DIR}/forklift \$@
EOF
chmod 755 ${FLBIN_DIR}/forklift
if ! grep -qF "forklift" ~/.bash_profile; then
echo "Adding forklift to path by modifying ~/.bash_profile"
echo "export PATH=\"\${PATH}:${FLBIN_DIR}\"" >> ~/.bash_profile
echo -e "${CFMT_SUCCESS}Succes${CFMT_NORMAL} (please create a new bash shell to use forklift)!"
else
echo -e "${CFMT_SUCCESS}Succes${CFMT_NORMAL}!"
fi
else
echo -e "${CFMT_SUCCESS}Succes${CFMT_NORMAL}!"
fi