-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
92 lines (70 loc) · 1.99 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
#!/bin/bash
SCRIPT_PATH="$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PLUGIN_PATH="${HOME}/.local/share/rhythmbox/plugins/rhythmbox-telegram"
GLIB_SCHEME="org.gnome.rhythmbox.plugins.telegram.gschema.xml"
GLIB_DIR="/usr/share/glib-2.0/schemas"
function uninstall {
rm -rf "${PLUGIN_PATH}"
sudo rm "${GLIB_DIR}/${GLIB_SCHEME}"
sudo glib-compile-schemas "${GLIB_DIR}/"
echo "Plugin uninstalled"
exit 0
}
################################ USAGE #######################################
usage=$(
cat <<EOF
Usage:
$0 [OPTION]
-h, --help show this message.
-u, --uninstall uninstall the plugin
EOF
)
########################### OPTIONS PARSING #################################
#parse options
TMP=`getopt --name=$0 -a --longoptions=help,uninstall -o u,h -- $@`
if [[ $? == 1 ]]
then
echo
echo "$usage"
exit
fi
eval set -- $TMP
until [[ $1 == -- ]]; do
case $1 in
-h|--help)
echo "$usage"
exit
;;
-u|--uninstall)
uninstall
exit
;;
esac
shift
done
shift # remove the '--', now $1 positioned at first argument if any
########################## INSTALLATION ################################
# build the dirs
mkdir -p "${PLUGIN_PATH}"
# copy the files
cp -r "${SCRIPT_PATH}/"* "$PLUGIN_PATH"
# install requirements
pip3 install -r "$PLUGIN_PATH/requirements.txt" -t "$PLUGIN_PATH/lib"
# install the glib schema
echo "Installing the glib schema (password needed)"
sudo cp "${PLUGIN_PATH}/${GLIB_SCHEME}" "$GLIB_DIR/"
sudo glib-compile-schemas "$GLIB_DIR/"
arch=$(uname -m)
case "$arch" in
x86_64) ;;
*)
if [[ "$(ldconfig -p | grep tdjson)" == "" ]]; then
echo "TDLib library is required to run this application." >&2
echo "Installation instructions are available on GitHub: https://github.com/tdlib/td" >&2
exit 127
fi
;;
esac
echo "Installation completed."
echo "Please restart Rhythmbox and enable the plugin in the settings."
exit 0