-
Notifications
You must be signed in to change notification settings - Fork 2
/
install.sh
executable file
·122 lines (101 loc) · 5.18 KB
/
install.sh
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
# install.sh / uninstall.sh - Install or uninstall software
_prefixDir="$HOME/opt"
# Provider of the software, e.g. project name or similar
_provider="clusterd"
_product="gsatellite"
# user install activated? 0 => no, 1 => yes
_userInstall=1
# if a (prefix) directory is provided, switch to system install
if [[ "$1" != "" ]]; then
_prefixDir="$1"
_userInstall=0
fi
# installation
if [[ "$(basename $0)" == "install.sh" ]]; then
# first create bin dir in home, if not already existing (only for user
#+ install!)
if [[ $_userInstall -eq 1 ]]; then
if [[ ! -e "$HOME/bin" ]]; then
mkdir -p "$HOME/bin" &>/dev/null
fi
fi
# create base directory
mkdir -p "$_prefixDir/$_provider/$_product" &>/dev/null
# create directory for configuration files and also copy configuration
#+ files
if [[ $_userInstall -eq 1 ]]; then
mkdir -p "$HOME/.$_product" &>/dev/null
cp ./etc/paths.conf "$HOME/.$_product/paths.conf"
else
cp ./etc/paths.conf "$_prefixDir/$_provider/$_product/etc/paths.conf"
fi
# copy scripts and libs
cp -rd ./bin "$_prefixDir/$_provider/$_product/"
cp -rd ./lib "$_prefixDir/$_provider/$_product/"
cp -rd ./libexec "$_prefixDir/$_provider/$_product/"
# reconfigure paths inside of the scripts and configurations files
# + reconfigure path to configuration files
# |
# | + remove (special) comments
# | |
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/gsatctl.bash"
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/gqstat.bash"
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/gsatlc.bash"
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/sendcmd.bash"
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/sigfwd.bash"
sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -e 's/#sed#//g' -i "$_prefixDir/$_provider/$_product/bin/sputnik.bash"
# not needed any longer
#if [[ $_userInstall -eq 1 ]]; then
# sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -i "$HOME/.$_product/paths.conf"
#else
# sed -e "s|<PATH_TO_GSATELLITE>|$_prefixDir/$_provider/$_product|g" -i "$_prefixDir/$_provider/$_product/etc/paths.conf"
#fi
# if this is a user install create links in "$HOME/bin"
if [[ $_userInstall -eq 1 ]]; then
linkPath="$HOME"
ln -s "$_prefixDir/$_provider/$_product/bin/gsatctl.bash" "$linkPath/bin/gsatctl" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gqstat.bash" "$linkPath/bin/gqstat" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatctl.bash" "$linkPath/bin/gqsub" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatctl.bash" "$linkPath/bin/gqhold" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatctl.bash" "$linkPath/bin/gqrls" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatctl.bash" "$linkPath/bin/gqdel" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/sendcmd.bash" "$linkPath/bin/sendcmd" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatlc.bash" "$linkPath/bin/gsatlc" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/gsatlcd.bash" "$linkPath/bin/gsatlcd" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/sigfwd.bash" "$linkPath/bin/sigfwd" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/sigfwdd.bash" "$linkPath/bin/sigfwdd" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/sputnik.bash" "$linkPath/bin/sputnik" &>/dev/null
ln -s "$_prefixDir/$_provider/$_product/bin/sputnikd.bash" "$linkPath/bin/sputnikd" &>/dev/null
fi
# copy README and manpages
cp -r ./share "$_prefixDir/$_provider/$_product/"
# uninstallation
elif [[ "$(basename $0)" == "uninstall.sh" ]]; then
# remove a system installed gtransfer
if [[ ! $_userInstall -eq 1 ]]; then
rm -rf "$_prefixDir/$_provider/$_product"
rmdir --ignore-fail-on-non-empty "$_prefixDir/$_provider"
# remove a user installed gtransfer
else
# remove scripts and links "$HOME/bin"
rm "$HOME/bin/gsatctl" \
"$HOME/bin/gqstat" \
"$HOME/bin/gqsub" \
"$HOME/bin/gqhold" \
"$HOME/bin/gqrls" \
"$HOME/bin/gqdel" \
"$HOME/bin/sendcmd" \
"$HOME/bin/gsatlc" \
"$HOME/bin/gsatlcd" \
"$HOME/bin/sigfwd" \
"$HOME/bin/sigfwdd" \
"$HOME/bin/sputnik" \
"$HOME/bin/sputnikd"
# remove gtransfer dir
rm -rf "$_prefixDir/$_provider/$_product"
rmdir --ignore-fail-on-non-empty "$_prefixDir/$_provider"
# remove basedir configuration files, etc.
rm -rf "$HOME/.$_product"
fi
fi