-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuninstall.sh
executable file
·165 lines (139 loc) · 4.38 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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#******************************************************************************#
# #
# uninstall.sh #
# #
#******************************************************************************#
# #
# This script uninstalls an app to a Sharedigm platform instance. #
# #
# Author(s): Abe Megahed #
# #
# This file is subject to the terms and conditions defined in #
# 'LICENSE.md', which is part of this source code distribution. #
# #
#******************************************************************************#
# Copyright (C) 2016 - 2025, Megahed Labs LLC, www.sharedigm.com #
#******************************************************************************#
# the app to uninstall
#
appname="theme_picker"
#
# functions
#
function println {
if [ $force != 1 ]; then
echo $1
fi
}
#******************************************************************************#
# client uninstallation functions #
#******************************************************************************#
function uninstall_configs {
println "Uninstalling configs."
# Uninstall from launcher
#
jq "del(.$appname)" $target/config/apps.json --tab > apps.json
mv apps.json $target/config/apps.json
# Uninstall from preferences
#
jq "del(.$appname)" $target/config/preferences.json --tab > preferences.json
mv preferences.json $target/config/preferences.json
}
function uninstall_scripts {
println "Uninstalling scripts."
scripts=$target/scripts/views/apps/$dirname
if [ -d $scripts ]; then
rm -rf $scripts
fi
}
function uninstall_styles {
println "Uninstall styles."
styles=$target/styles/apps/_$dirname.scss
if [ -f $styles ]; then
rm -f $styles
# remove reference from _index.scss
#
use="@use \"$dirname\";"
sed -i -e "s/\n$use//g" $target/styles/apps/_index.scss
sed -i -e "/$use/d" $target/styles/apps/_index.scss
# remove backup files (MacOS)
#
if [ -f $target/styles/apps/_index.scss-e ]; then
rm $target/styles/apps/_index.scss-e
fi
if [ $force != 1 ]; then
sass $target/styles/styles.scss $target/styles/styles.css
fi
fi
}
function uninstall_resources {
println "Uninstalling resources."
resources=$target/resources/$dirname
if [ -d $resources ]; then
rm -rf $resources
fi
}
function uninstall_templates {
println "Uninstalling templates."
# Uninstall from documentation templates
#
if [ -f $target/templates/apps/$dirname.tpl ]; then
rm $target/templates/apps/$dirname.tpl
fi
}
function uninstall_images {
println "Uninstalling images."
# Uninstall app icon image.
#
if [ -f $target/images/icons/apps/$dirname.svg ]; then
rm $target/images/icons/apps/$dirname.svg
fi
# Uninstall documentation images.
#
if [ -d $target/images/info/apps/$dirname ]; then
rm -r $target/images/info/apps/$dirname
fi
}
# check command line arguments
#
if [ "$1" == "" ] || [ $# -gt 2 ]; then
echo "Usage: sh uninstall.sh SHAREDIGM_DIRECTORY"
exit 0
fi
#******************************************************************************#
# main #
#******************************************************************************#
# parse command line arguments
#
target=$1
force=0
if [ $# -eq 2 ] && [ "$2" == "-f" ]; then
force=1
fi
# confirm uninstall
#
if [ $force != 1 ]; then
println "Would you like to uninstall $appname from $target (Y/N)?"
read prompt
if [ $prompt != 'y' ] && [ $prompt != 'Y' ]; then
println "Quitting."
exit 0
fi
fi
# proceed with uninstall
#
println "Uninstalling $appname from $target..."
# find name of app directory
#
dirname=${appname//_/-}
# uninstall app components
#
uninstall_configs
uninstall_scripts
uninstall_styles
uninstall_resources
uninstall_templates
uninstall_images
# finished
#
println "Uninstallation complete."