forked from nigma/StackScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·44 lines (36 loc) · 1.24 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
#!/bin/bash
sudo apt-get -y update
sudo apt-get -y upgrade
INSTALL_LOCATION="/usr/local/lib/bash_stack"
INSTALL_LOCATION_BIN="/usr/local/bin"
#INSTALL_LOCATION="/Users/dkb/bash_stack"
if [ "$1" ] ; then
INSTALL_LOCATION="$1"
fi
#remove trailing '/'
INSTALL_LOCATION=$(echo "$INSTALL_LOCATION" | sed 's/\/$//g')
#install lib directory if lib directory exists
if [ -d ./lib ] ; then
echo "Installing to: $INSTALL_LOCATION"
# remove previous installation if it exists
rm -rf "$INSTALL_LOCATION"
mkdir -p "$INSTALL_LOCATION/lib"
mkdir -p "$INSTALL_LOCATION/bin"
cp -r ./lib/* "$INSTALL_LOCATION/lib"
cp ./bash_stack.sh "$INSTALL_LOCATION"
cp -r ./default_html "$INSTALL_LOCATION"
if [ -d ./default_conf ] ; then
cp -r ./default_conf "$INSTALL_LOCATION"
fi
cp -r ./templates "$INSTALL_LOCATION"
cp -r ./bin/* "$INSTALL_LOCATION_BIN"
for shellFile in "$INSTALL_LOCATION_BIN/"*
do
chmod +x "$shellFile"
done
echo '#!/bin/bash' > "$INSTALL_LOCATION/tmp.tmp.sh"
echo "BASH_STACK_INSTALL_DIR=\"$INSTALL_LOCATION\"" >> "$INSTALL_LOCATION/tmp.tmp.sh"
cat "$INSTALL_LOCATION/bash_stack.sh" >> "$INSTALL_LOCATION/tmp.tmp.sh"
mv "$INSTALL_LOCATION/tmp.tmp.sh" "$INSTALL_LOCATION/bash_stack.sh"
fi
source $INSTALL_LOCATION/bash_stack.sh