-
Notifications
You must be signed in to change notification settings - Fork 3
/
uninstall.sh
executable file
·67 lines (60 loc) · 2.59 KB
/
uninstall.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
#! /bin/bash
#
# Part of kde-service-menu-reimage (version 2.6.0)
# Copyright (C) 2018-2019 Giuseppe Benigno <giuseppe.benigno(at)gmail.com>
# Copyright (C) 2024 Irfan Hakim <irfanhakim.as(at)yahoo.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# environment variables
qtpaths_bin="${qtpaths_bin:-"qtpaths"}"
user_install_prefix="${user_install_prefix:-"${HOME}/.local"}"
# local variables
required_vars=("bin_dir" "servicemenu_dir" "doc_dir")
servicemenu_files=($(shopt -s nullglob; for f in ServiceMenus/*.desktop; do basename "${f}"; done))
# determine installation directories
if [[ ${EUID} -eq 0 ]]; then
bin_dir="$(${qtpaths_bin} --install-prefix)/bin"
servicemenu_dir="$(${qtpaths_bin} --locate-dirs GenericDataLocation kio/servicemenus | sed 's/.*://')"
doc_dir="$(${qtpaths_bin} --install-prefix)/share/doc/kde-service-menu-reimage/"
install_mode="system"
else
bin_dir="${user_install_prefix}/bin"
servicemenu_dir="$(${qtpaths_bin} --locate-dirs GenericDataLocation kio/servicemenus | sed 's/:.*//')"
doc_dir="${user_install_prefix}/share/doc/kde-service-menu-reimage/"
install_mode="local"
fi
# ensure all required variables are set
for var in "${required_vars[@]}"; do
if [ -z "${!var}" ]; then
echo "ERROR: Required variable ${var} was not set successfully. Aborting installation of kde-service-menu-reimage."
exit 1
fi
done
echo "Uninstalling kde-service-menu-reimage (${install_mode}) ..."
# remove required binaries
echo "Removing ${bin_dir}/reimage-kdialog" && rm -f "${bin_dir}/reimage-kdialog" && \
# remove required service menus
for file in "${servicemenu_files[@]}"; do
echo "Removing ${servicemenu_dir}/${file}" && rm -f "${servicemenu_dir}/${file}"
done && \
# remove documentation files
echo "Removing ${doc_dir}" && rm -rf "${doc_dir}"
# report uninstallation result
if [ ${?} -eq 0 ]; then
echo "SUCCESS: kde-service-menu-reimage has been uninstalled successfully."
else
echo "ERROR: kde-service-menu-reimage uninstallation failed."
exit 1
fi