wok view kleanny/stuff/kleanny @ rev 20040

Add: Kleanny v1.0 By The SliTaz DevTeam.
author Leonardo Laporte <hackdorte@yandex.com>
date Sun Aug 27 10:17:57 2017 -0300 (2017-08-27)
parents
children 39130a1f0dd8
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 # ----------------------------------------------------------------------------
23 # Check DEPENDS
25 CHK_BASH="/var/lib/tazpkg/installed/bash" # Check Bash
26 CHK_YAD="/var/lib/tazpkg/installed/yad-gtk2-html" # Check Yad with HTML.
27 CHK_SVG="/var/lib/tazpkg/installed/librsvg" # Check Librsvg.
28 CHK_FAIL="file:///$localdata/base/deps.fail.html" # Report missing DEPS.
30 # ----------------------------------------------------------------------------
31 # It is important to check if any dependencies have been removed by user.
33 checkDEPS(){
34 if [ -e "$CHK_BASH" ] && [ -e "$CHK_YAD" ] && [ -e "$CHK_SVG" ]
35 then
36 # OK! Let's check the logs now...
37 checkLOG
38 else
39 # Oops! Let's report the problem in the default browser.
40 browser $CHK_FAIL
41 exit
42 fi
43 }
45 # ----------------------------------------------------------------------------
46 # Search caches and files to be reported (LOGFILE).
47 #
48 # !! To add new entries please enter only the caches.
49 # Keep the configuration files off the list.
50 #
51 # Example:
52 #
53 # $userdir/.thunderbird >> Includes settings. This is not good.
54 # $userdir/.cache/thunderbird >> Includes cache only. That's nice!
56 ASH_HISTORY="$userdir/.ash_history"
57 BASH_HISTORY="$userdir/.bash_history"
58 CACHE_THUMBNAILS="$userdir/.thumbnails"
59 CACHE_MIDORI="$userdir/.cache/midori"
60 CACHE_TRANSMISSION="$userdir/.cache/transmission"
61 CACHE_WINE="$userdir/.cache/wine"
62 CACHE_GCHROME="$userdir/.cache/google-chrome"
63 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
65 # ----------------------------------------------------------------------------
66 # Write the report of caches and files to remove (REMFILE).
68 CLEAN_THUMBNAILS="$CACHE_THUMBNAILS/*" # Thumbnails images cache.
69 CLEAN_MIDORI="$CACHE_MIDORI/*" # Midori Browser cache.
70 CLEAN_TRANSMISSION="$CACHE_TRANSMISSION/*" # Transmission P2P cache.
71 CLEAN_WINE="$CACHE_WINE/*" # Wine user cache.
72 CLEAN_GCHROME="$CACHE_GCHROME/*" # Google Chrome cache.
73 CLEAN_THUNDERBIRD="$CACHE_THUNDERBIRD/*" # Thunderbird cache.
75 # ----------------------------------------------------------------------------
76 # Settings to directory temporary and logs
78 CREATE_LOG_DIR="$(mkdir -p $tmpdir)" # Create the log directory.
79 SET_TMPDIR_TO_ALL="$(chmod 777 $tmpdir)" # Set permission to log directory.
80 LOGFILE="status.log" # Report: Caches and files to read.
81 REMFILE="remove.log" # Report: Caches and files to remove.
82 DEL_OLD_LOGS="$(rm -rf $tmpdir/$LOGFILE $tmpdir/$REMFILE)" # Delete old logs.
84 export APP_LOGFILE="$tmpdir/$LOGFILE" # Recognize the output to status.log.
85 export APP_REMFILE="$tmpdir/$REMFILE" # Recognize the output to remove.log.
87 # ----------------------------------------------------------------------------
88 # Check the old logs to avoid conflicts with future verification.
89 #
90 # !! Kleanny needs this action to verify that the user uninstalls some
91 # software and an old log is no longer useful. This is important!
93 # @@ The first step the application should do.
94 checkLOG(){
95 [ -e "$tmpdir" ] && $DEL_OLD_LOGS || $CREATE_LOG_DIR
96 writeLOG
97 }
99 # @@ Write the log files.
100 writeLOG(){
102 # ----------------------------------------------------------------------------
103 # Report caches and files to status (status.log).
105 cat <<-'LOG' >> ${APP_LOGFILE}
106 # Automatically generated by KLEANNY Application.
107 # The list of caches and files to be reported.
108 # [ dir: /tmp/kleanny/status.log ]
110 ASH_HISTORY="$userdir/.ash_history"
111 BASH_HISTORY="$userdir/.bash_history"
112 CACHE_THUMBNAILS="$userdir/.thumbnails"
113 CACHE_MIDORI="$userdir/.cache/midori"
114 CACHE_TRANSMISSION="$userdir/.cache/transmission"
115 CACHE_WINE="$userdir/.cache/wine"
116 CACHE_GCHROME="$userdir/.cache/google-chrome"
117 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
119 CACHES="$(echo \
120 LOG
122 # ----------------------------------------------------------------------------
123 # Report caches and files to cleanup action (remove.log).
125 cat <<-'DELETE' >> ${APP_REMFILE}
126 # Automatically generated by KLEANNY Application.
127 # The list of caches and files to be removed.
128 # ******** Please do not edit this file. ********
129 # [ dir: /tmp/kleanny/remove.log ]
131 ASH_HISTORY="$userdir/.ash_history"
132 BASH_HISTORY="$userdir/.bash_history"
133 CACHE_THUMBNAILS="$userdir/.thumbnails"
134 CACHE_MIDORI="$userdir/.cache/midori"
135 CACHE_TRANSMISSION="$userdir/.cache/transmission"
136 CACHE_WINE="$userdir/.cache/wine"
137 CACHE_GCHROME="$userdir/.cache/google-chrome"
138 CACHE_THUNDERBIRD="$userdir/.cache/thunderbird"
140 CLEAN_THUMBNAILS="$CACHE_THUMBNAILS/*"
141 CLEAN_MIDORI="$CACHE_MIDORI/*"
142 CLEAN_TRANSMISSION="$CACHE_TRANSMISSION/*"
143 CLEAN_WINE="$CACHE_WINE/*"
144 CLEAN_GCHROME="$CACHE_GCHROME/*"
145 CLEAN_THUNDERBIRD="$CACHE_THUNDERBIRD/*"
147 cleanup(){
148 DELETE
150 if [ -e "$ASH_HISTORY" ]
151 then
152 cat <<-'LOG' >> ${APP_LOGFILE}
153 $ASH_HISTORY \
154 LOG
155 cat <<-'DELETE' >> ${APP_REMFILE}
156 rm -rf $ASH_HISTORY && touch $ASH_HISTORY && chmod 777 $ASH_HISTORY
157 DELETE
158 fi
160 if [ -e "$BASH_HISTORY" ]
161 then
162 cat <<-'LOG' >> ${APP_LOGFILE}
163 $BASH_HISTORY \
164 LOG
165 cat <<-'DELETE' >> ${APP_REMFILE}
166 rm -rf $BASH_HISTORY && touch $BASH_HISTORY && chmod 777 $BASH_HISTORY
167 DELETE
168 fi
170 if [ -e "$CACHE_THUMBNAILS" ]
171 then
172 cat <<-'LOG' >> ${APP_LOGFILE}
173 $CACHE_THUMBNAILS \
174 LOG
175 cat <<-'DELETE' >> ${APP_REMFILE}
176 rm -rf $CLEAN_THUMBNAILS
177 DELETE
178 fi
180 if [ -e "$CACHE_MIDORI" ]
181 then
182 cat <<-'LOG' >> ${APP_LOGFILE}
183 $CACHE_MIDORI \
184 LOG
185 cat <<-'DELETE' >> ${APP_REMFILE}
186 rm -rf $CLEAN_MIDORI
187 DELETE
188 fi
190 if [ -e "$CACHE_TRANSMISSION" ]
191 then
192 cat <<-'LOG' >> ${APP_LOGFILE}
193 $CACHE_TRANSMISSION \
194 LOG
195 cat <<-'DELETE' >> ${APP_REMFILE}
196 rm -rf $CLEAN_TRANSMISSION
197 DELETE
198 fi
200 if [ -e "$CACHE_WINE" ]
201 then
202 cat <<-'LOG' >> ${APP_LOGFILE}
203 $CACHE_WINE \
204 LOG
205 cat <<-'DELETE' >> ${APP_REMFILE}
206 rm -rf $CLEAN_WINE
207 DELETE
208 fi
210 if [ -e "$CACHE_GCHROME" ]
211 then
212 cat <<-'LOG' >> ${APP_LOGFILE}
213 $CACHE_GCHROME \
214 LOG
215 cat <<-'DELETE' >> ${APP_REMFILE}
216 rm -rf $CLEAN_GCHROME
217 DELETE
218 fi
220 if [ -e "$CACHE_THUNDERBIRD" ]
221 then
222 cat <<-'LOG' >> ${APP_LOGFILE}
223 $CACHE_THUNDERBIRD)"
224 LOG
225 cat <<-'DELETE' >> ${APP_REMFILE}
226 rm -rf $CLEAN_THUNDERBIRD
227 DELETE
228 fi
230 cat <<-'DELETE' >> ${APP_REMFILE}
231 }
232 DELETE
234 cat <<-'DELETE' >> ${APP_LOGFILE}
236 STATUS_REPORT="$(du -hcs $CACHES | grep total | sed 's/[*total* ]//g')"
238 DELETE
240 # @@ Set the correct permission for the temporary directory and all files.
241 $SET_TMPDIR_TO_ALL
243 # @@ Call Kleanny startup.
244 startUP
246 }
248 startUP(){
250 # @@ A beautiful splash screen.
251 splash=$(yad --gtkrc="$localtheme/gtkrc" \
252 --window-icon="$localicon/48/kleanny.png" \
253 --title="$APP_NAME" --center \
254 --image="$localtheme/splashscreen.svg" \
255 --no-buttons --undecorated --timeout="3" \
256 --auto-close --auto-kill)
258 # Launch Kleanny.
259 kleanny=$(yad --gtkrc="$localtheme/gtkrc" \
260 --window-icon="$localicon/48/kleanny.png" \
261 --title="$APP_NAME" --center --no-buttons \
262 --browser --html --mime="text/html" \
263 --width="320" --height="481" --undecorated \
264 --borders="0" --uri="$localwww/res/base/status.cgi")
266 }
268 # @@ First step.
269 checkDEPS