-
Notifications
You must be signed in to change notification settings - Fork 3
/
install.sh
executable file
·80 lines (56 loc) · 1.56 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
#!/bin/sh
Install () {
LOCATION="source/"
echo "Beginning installation..."
mkdir -p "${1}"
chown $(logname): "${1}"
if [ -e "${1}/res" ]; then
cp -pvi ${LOCATION}* ${1}
else
cp -rpvi ${LOCATION}* ${1}
fi
case "$1" in
/*) ABSOLUTE_PATH=""$1"codedict";;
*) ABSOLUTE_PATH="$(pwd)/"$1"codedict";;
esac
EXECTEXT='#!/bin/sh \n \n'${ABSOLUTE_PATH}' $@'
case "$3" in
*/) ABSOLUTE_PATH=""$1"codedict";;
*) ABSOLUTE_PATH="$(pwd)/"$1"codedict";;
esac
echo "$EXECTEXT" > ${2}"codedict"
chmod +x ${2}"codedict"
}
if [ -e source/ ]; then
INSTALLDIR=$1
EXECUTABLEDIR=$2
if [ ! $INSTALLDIR ]; then
INSTALLDIR="./"
fi
if [ ! $EXECUTABLEDIR ]; then
EXECUTABLEDIR="/usr/local/bin/"
fi
case "$INSTALLDIR" in
*/) INSTALLDIR=$INSTALLDIR;;
*) INSTALLDIR=$INSTALLDIR"/";;
esac
case "$EXECUTABLEDIR" in
*/) EXECUTABLEDIR=$EXECUTABLEDIR;;
*) EXECUTABLEDIR=$EXECUTABLEDIR"/";;
esac
echo "\
Installing from source.\n\
All files will be placed into "\'$INSTALLDIR\'" .\n\
The actual executable will be placed into "\'$EXECUTABLEDIR\'" ."
while true; do
read -p "Do you wish to install this program? (y/n) " yn
case $yn in
[Yy]* ) Install $INSTALLDIR $EXECUTABLEDIR; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no. (y/n) ";;
esac
done
else
echo "Installation error - missing files."
exit
fi