wok view kleanny/stuff/kleanny @ rev 20959

updated gdbm (1.10 -> 1.18.1)
author Hans-G?nter Theisgen
date Mon Mar 04 16:00:34 2019 +0100 (2019-03-04)
parents 5f4f5cda01ff
children
line source
1 #!/bin/bash
2 #
3 # Provided By The SliTaz Development Team.
4 # Copyright (C) 2017 The SliTaz Association.
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19 # @@ Kleanny Database.
20 . /var/www/cgi-bin/kleanny/res/base/data
22 export kleanny="/usr/bin/kleanny"
24 # ----------------------------------------------------------------------------
25 # Check DEPENDS
27 CHK_BASH="/var/lib/tazpkg/installed/bash" # Check Bash
28 CHK_YAD="/var/lib/tazpkg/installed/yad-gtk2-html" # Check Yad with HTML.
29 CHK_SVG="/var/lib/tazpkg/installed/librsvg" # Check Librsvg.
30 CHK_FAIL="file:///$localdata/base/deps.fail.html" # Report missing DEPS.
32 # ----------------------------------------------------------------------------
33 # It is important to check if any dependencies have been removed by user.
35 checkDEPS(){
36 if [ -e "$CHK_BASH" ] && [ -e "$CHK_YAD" ] && [ -e "$CHK_SVG" ]
37 then
38 # OK! Let's check the logs now...
39 checkLOG
40 else
41 # Oops! Let's report the problem in the default browser.
42 browser $CHK_FAIL
43 exit
44 fi
45 }
47 # ----------------------------------------------------------------------------
48 # Search caches and files to be reported (LOGFILE).
49 #
50 # !! To add new entries please enter only the caches.
51 # Keep the configuration files off the list.
52 #
53 # Example:
54 #
55 # $userdir/.thunderbird >> Includes settings. This is not good.
56 # $userdir/.cache/thunderbird >> Includes cache only. That's nice!
58 ASH_HISTORY="$userdir/.ash_history"
59 BASH_HISTORY="$userdir/.bash_history"
60 CACHE_THUMBNAILS="$userdir/.thumbnails"
61 CACHE_MIDORI="$userdir/.cache/midori"
62 CACHE_TRANSMISSION="$userdir/.cache/transmission"
63 CACHE_WINE="$userdir/.cache/wine"
64 CACHE_GCHROME="$userdir/.cache/google-chrome"
65 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
67 # ----------------------------------------------------------------------------
68 # Write the report of caches and files to remove (REMFILE).
70 CLEAN_THUMBNAILS="$CACHE_THUMBNAILS/*" # Thumbnails images cache.
71 CLEAN_MIDORI="$CACHE_MIDORI/*" # Midori Browser cache.
72 CLEAN_TRANSMISSION="$CACHE_TRANSMISSION/*" # Transmission P2P cache.
73 CLEAN_WINE="$CACHE_WINE/*" # Wine user cache.
74 CLEAN_GCHROME="$CACHE_GCHROME/*" # Google Chrome cache.
75 CLEAN_THUNDERBIRD="$CACHE_THUNDERBIRD/*" # Thunderbird cache.
77 # ----------------------------------------------------------------------------
78 # Settings to directory temporary and logs
80 CREATE_LOG_DIR="$(mkdir -p $tmpdir)" # Create the log directory.
81 SET_TMPDIR_TO_ALL="$(chmod 777 $tmpdir)" # Set permission to log directory.
82 LOGFILE="status.log" # Report: Caches and files to read.
83 REMFILE="remove.log" # Report: Caches and files to remove.
84 DEL_OLD_LOGS="$(rm -rf $tmpdir/$LOGFILE $tmpdir/$REMFILE)" # Delete old logs.
86 export APP_LOGFILE="$tmpdir/$LOGFILE" # Recognize the output to status.log.
87 export APP_REMFILE="$tmpdir/$REMFILE" # Recognize the output to remove.log.
89 # ----------------------------------------------------------------------------
90 # Check the old logs to avoid conflicts with future verification.
91 #
92 # !! Kleanny needs this action to verify that the user uninstalls some
93 # software and an old log is no longer useful. This is important!
95 # @@ The first step the application should do.
96 checkLOG(){
97 [ -e "$tmpdir" ] && $DEL_OLD_LOGS || $CREATE_LOG_DIR
98 writeLOG
99 }
101 # @@ Write the log files.
102 writeLOG(){
104 # ----------------------------------------------------------------------------
105 # Report caches and files to status (status.log).
107 cat <<-'LOG' >> ${APP_LOGFILE}
108 # Automatically generated by KLEANNY Application.
109 # The list of caches and files to be reported.
110 # [ dir: /tmp/kleanny/status.log ]
112 ASH_HISTORY="$userdir/.ash_history"
113 BASH_HISTORY="$userdir/.bash_history"
114 CACHE_THUMBNAILS="$userdir/.thumbnails"
115 CACHE_MIDORI="$userdir/.cache/midori"
116 CACHE_TRANSMISSION="$userdir/.cache/transmission"
117 CACHE_WINE="$userdir/.cache/wine"
118 CACHE_GCHROME="$userdir/.cache/google-chrome"
119 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
121 CACHES="$(echo \
122 LOG
124 # ----------------------------------------------------------------------------
125 # Report caches and files to cleanup action (remove.log).
127 cat <<-'DELETE' >> ${APP_REMFILE}
128 # Automatically generated by KLEANNY Application.
129 # The list of caches and files to be removed.
130 # ******** Please do not edit this file. ********
131 # [ dir: /tmp/kleanny/remove.log ]
133 ASH_HISTORY="$userdir/.ash_history"
134 BASH_HISTORY="$userdir/.bash_history"
135 CACHE_THUMBNAILS="$userdir/.thumbnails"
136 CACHE_MIDORI="$userdir/.cache/midori"
137 CACHE_TRANSMISSION="$userdir/.cache/transmission"
138 CACHE_WINE="$userdir/.cache/wine"
139 CACHE_GCHROME="$userdir/.cache/google-chrome"
140 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
142 CLEAN_THUMBNAILS="$CACHE_THUMBNAILS/*"
143 CLEAN_MIDORI="$CACHE_MIDORI/*"
144 CLEAN_TRANSMISSION="$CACHE_TRANSMISSION/*"
145 CLEAN_WINE="$CACHE_WINE/*"
146 CLEAN_GCHROME="$CACHE_GCHROME/*"
147 CLEAN_THUNDERBIRD="$CACHE_THUNDERBIRD/*"
149 cleanup(){
150 DELETE
152 if [ -e "$ASH_HISTORY" ]
153 then
154 cat <<-'LOG' >> ${APP_LOGFILE}
155 $ASH_HISTORY \
156 LOG
157 cat <<-'DELETE' >> ${APP_REMFILE}
158 rm -rf $ASH_HISTORY && touch $ASH_HISTORY && chmod 777 $ASH_HISTORY
159 DELETE
160 fi
162 if [ -e "$BASH_HISTORY" ]
163 then
164 cat <<-'LOG' >> ${APP_LOGFILE}
165 $BASH_HISTORY \
166 LOG
167 cat <<-'DELETE' >> ${APP_REMFILE}
168 rm -rf $BASH_HISTORY && touch $BASH_HISTORY && chmod 777 $BASH_HISTORY
169 DELETE
170 fi
172 if [ -e "$CACHE_THUMBNAILS" ]
173 then
174 cat <<-'LOG' >> ${APP_LOGFILE}
175 $CACHE_THUMBNAILS \
176 LOG
177 cat <<-'DELETE' >> ${APP_REMFILE}
178 rm -rf $CLEAN_THUMBNAILS
179 DELETE
180 fi
182 if [ -e "$CACHE_MIDORI" ]
183 then
184 cat <<-'LOG' >> ${APP_LOGFILE}
185 $CACHE_MIDORI \
186 LOG
187 cat <<-'DELETE' >> ${APP_REMFILE}
188 rm -rf $CLEAN_MIDORI
189 DELETE
190 fi
192 if [ -e "$CACHE_TRANSMISSION" ]
193 then
194 cat <<-'LOG' >> ${APP_LOGFILE}
195 $CACHE_TRANSMISSION \
196 LOG
197 cat <<-'DELETE' >> ${APP_REMFILE}
198 rm -rf $CLEAN_TRANSMISSION
199 DELETE
200 fi
202 if [ -e "$CACHE_WINE" ]
203 then
204 cat <<-'LOG' >> ${APP_LOGFILE}
205 $CACHE_WINE \
206 LOG
207 cat <<-'DELETE' >> ${APP_REMFILE}
208 rm -rf $CLEAN_WINE
209 DELETE
210 fi
212 if [ -e "$CACHE_GCHROME" ]
213 then
214 cat <<-'LOG' >> ${APP_LOGFILE}
215 $CACHE_GCHROME \
216 LOG
217 cat <<-'DELETE' >> ${APP_REMFILE}
218 rm -rf $CLEAN_GCHROME
219 DELETE
220 fi
222 if [ -e "$CACHE_THUNDERBIRD" ]
223 then
224 cat <<-'LOG' >> ${APP_LOGFILE}
225 $CACHE_THUNDERBIRD)"
226 LOG
227 cat <<-'DELETE' >> ${APP_REMFILE}
228 rm -rf $CLEAN_THUNDERBIRD
229 DELETE
230 fi
232 cat <<-'DELETE' >> ${APP_REMFILE}
233 }
234 DELETE
236 cat <<-'DELETE' >> ${APP_LOGFILE}
238 STATUS_REPORT="$(du -hcs $CACHES | grep total | sed 's/[*total* ]//g')"
240 DELETE
242 # @@ Set the correct permission for the temporary directory and all files.
243 $SET_TMPDIR_TO_ALL
245 # @@ Call Kleanny startup.
246 startUP
248 }
250 startUP(){
252 # @@ A beautiful splash screen.
253 splash=$(yad --gtkrc="$localtheme/gtkrc" \
254 --window-icon="$localicon/48/kleanny.png" \
255 --title="$APP_NAME" --center \
256 --image="$localtheme/splashscreen.svg" \
257 --no-buttons --undecorated --timeout="3" \
258 --auto-close --auto-kill)
260 # Launch Kleanny.
261 kleanny=$(yad --gtkrc="$localtheme/gtkrc" \
262 --window-icon="$localicon/48/kleanny.png" \
263 --title="$APP_NAME" --center --no-buttons \
264 --browser --html --mime="text/html" \
265 --width="320" --height="481" --undecorated \
266 --borders="0" --uri="$localwww/res/base/status.cgi")
268 }
270 # @@ First step.
271 checkDEPS