-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·61 lines (47 loc) · 1.45 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
#!/bin/bash
# INSTALL CACHALOT 2
# get installation directory
echo "Enter directory path to install Cachalot binaries and data."
echo "(press enter to use default value /usr/local/lib/cachalot2/)"
echo " > "
read path
if [ "$path" == "" ] ; then
path="/usr/local/lib/cachalot2"
fi
echo "Installation into : '$path'"
# create installation dir
if [ ! -d "$path/data" ] ; then
mkdir -p "$path/data" || exit
fi
# copy program
cp cachalot2 $path/cachalot2 || exit
# create intermediate script
run="$path/cachalot2_run.sh"
touch $run || exit
echo '#!/bin/bash' > $run # erase content
echo "INSTALL_DIR=\"$path\"" >> $run
echo 'HISTORY_FILE=~/.cachalot2' >> $run
# get absolute path of the music file
echo 'FILE="$(pwd)/$1"' >> $run
# if $1 was absolute, reset FILE
echo '[ "$(echo "$1" | cut -b 1)" == "/" ] && FILE="$1"' >> $run
# if $1 was empty, reset FILE
echo '[ "$1" == "" ] && FILE=""' >> $run
echo 'cd $INSTALL_DIR' >> $run
echo './cachalot2 "$HISTORY_FILE" "$FILE"' >> $run
# set exection permission
chmod a+rx $path/cachalot2
chmod a+rx $path/cachalot2_run.sh
# copy data
echo "Copy of program data"
cp "data/jennaSue.ttf" "$path/data/jennaSue.ttf" || exit
cp "data/widget.png" "$path/data/widget.png"
# create callable file (link to intermediate script)
bin="/usr/local/bin/cachalot2"
if [ -f $bin ] ; then
rm $bin
fi
echo "Creation of the program link : '$bin'"
ln -s $path/cachalot2_run.sh $bin || exit
#chmod a+rx $bin || exit
echo "Installation successful !"