-
Notifications
You must be signed in to change notification settings - Fork 9
/
install.sh
executable file
·70 lines (58 loc) · 1.96 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
#!/bin/bash
SOURCE_PATH=$(dirname $(readlink -f $0))
DESTINATION_PREFIX="/usr/local"
if [ -n "$1" ];
then
DESTINATION_PREFIX="${1%/}"
echo
while true; do
read -p "Are you sure you want to install this program to '${DESTINATION_PREFIX}' prefix? " yn
case $yn in
[Yy]* ) break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
echo
fi
SHARE_PATH="${DESTINATION_PREFIX}/share"
APPLICATIONS_PATH="${SHARE_PATH}/applications"
BIN_PATH="${DESTINATION_PREFIX}/bin"
DESTINATION_PATH="${SHARE_PATH}/TinyPedal"
replace() {
PATTERN="$1"
STRING="$2"
while read LINE; do
echo "${LINE/${PATTERN}/${STRING}}"
done
}
if [ ! -f "pyRfactor2SharedMemory/__init__.py" ];
then
echo "Error: Missing files. Please, use a Linux source release file or 'git clone --recurse-submodules'."
exit 1
fi
if [ ! -w "${SHARE_PATH}" -o ! -w "${BIN_PATH}" -o ! -w "${APPLICATIONS_PATH}" ];
then
echo "Error: Insufficient privileges to install in prefix directory '${DESTINATION_PREFIX}' or it doesn't contain the required directories:"
echo -e " ${SHARE_PATH}, ${BIN_PATH}, ${APPLICATIONS_PATH}\n"
exit 1
fi
if [ -d "${DESTINATION_PATH}" ];
then
if [ -w "${DESTINATION_PATH}" ];
then
rm -r "${DESTINATION_PATH}"
else
echo "Error: Insufficient privileges to update existing install."
exit 1
fi
fi
echo "Writing ${DESTINATION_PATH}"
cp -r "${SOURCE_PATH}" "${DESTINATION_PATH}"
rm "${APPLICATIONS_PATH}/svictor-TinyPedal.desktop" "${BIN_PATH}/TinyPedal"
echo "Writing ${APPLICATIONS_PATH}/svictor-TinyPedal.desktop"
replace "/usr/local" "${DESTINATION_PREFIX}" <"${SOURCE_PATH}/svictor-TinyPedal.desktop" >"${APPLICATIONS_PATH}/svictor-TinyPedal.desktop"
echo "Writing ${BIN_PATH}/TinyPedal"
replace "./" "${DESTINATION_PATH}/" <"${SOURCE_PATH}/TinyPedal.sh" >"${BIN_PATH}/TinyPedal"
chmod a+x "${BIN_PATH}/TinyPedal"
echo "Installation finished."