forked from asermax/lastfm_extension
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·130 lines (103 loc) · 3.28 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
121
122
123
124
125
126
127
128
129
#!/bin/bash
################################ USAGE #######################################
usage=$(
cat <<EOF
Usage:
$0 [OPTION]
-h show this message.
-l, --local install the plugin locally (default).
-g, --global install the plugin globally.
--fingerprint-support install needed libraries for fingerprint support
EOF
)
########################### OPTIONS PARSING #################################
#parse options
TMP=`getopt --name=$0 -a --longoptions=local,global,help,fingerprint-support -o l,g,h -- $@`
if [[ $? == 1 ]]
then
echo
echo "$usage"
exit
fi
eval set -- $TMP
until [[ $1 == -- ]]; do
case $1 in
-l|--local)
LOCAL=true
;;
-g|--global)
LOCAL=false
;;
--fingerprint-support)
FINGERPRINT=true
;;
-h|--help)
echo "$usage"
exit
;;
esac
shift # move the arg list to the next option or '--'
done
shift # remove the '--', now $1 positioned at first argument if any
#default values
LOCAL=${LOCAL:=true}
FINGERPRINT=${FINGERPRINT:=false}
########################## START INSTALLATION ################################
#define constants
SCRIPT_NAME=`basename "$0"`
SCRIPT_PATH=${0%`basename "$0"`}
MATCHER="matcher.py"
#install the plugin; the install path depends on the install mode
if [[ $LOCAL == true ]]
then
echo "Installing plugin locally"
PLUGIN_PATH="${HOME}/.local/share/rhythmbox/plugins/lastfm_extension/"
#build the dirs
mkdir -p $PLUGIN_PATH
#copy the files
cp -r "${SCRIPT_PATH}"* "$PLUGIN_PATH"
#make the matcher executable
chmod +x "${PLUGIN_PATH}${MATCHER}"
#remove the install script from the dir (not needed)
rm "${PLUGIN_PATH}${SCRIPT_NAME}"
else
echo "Installing plugin globally(admin password needed)"
LIB_PATH="/usr/lib/rhythmbox/plugins/lastfm_extension/"
SHARE_PATH="/usr/share/rhythmbox/plugins/lastfm_extension/"
#build the dirs
sudo mkdir -p $LIB_PATH
sudo mkdir -p $SHARE_PATH
#copy the files
#lib files
declare -a libfiles=("lastfm_extension.plugin" "lastfm_extension.py"
"LastFMExtensionGenreGuesser.py"
"LastFMExtensionKeys.py" "LastFMExtensionUtils.py"
"LastFMExtensionGui.py" "pylast.py")
for item in "${libfiles[@]}"
do
sudo cp -r "${SCRIPT_PATH}$item" "$LIB_PATH"
done
#share files
declare -a sharefiles=("extensions" "img" "genres.txt" "matcher.py"
"lastfmExtensionConfigDialog.glade"
"lastfmExtensionFingerprintDialog.glade")
for item in "${sharefiles[@]}"
do
sudo cp -r "${SCRIPT_PATH}$item" "$SHARE_PATH"
done
#make the matcher executable
sudo chmod +x "${SHARE_PATH}${MATCHER}"
fi
#try to install pylastfp
if [[ $FINGERPRINT == true ]]
then
echo -n "Installing libraries needed for fingerprint support... "
sudo apt-get install python-pip libfftw3-dev libsamplerate0-dev > /dev/null 2>&1 && pip install pylastfp > /dev/null 2>&1
if [[ $? == 0 ]]
then
echo "Done"
else
echo "Failed"
fi
fi
echo "Finished installing the plugin. Enjoy :]"