wok annotate kleanny/stuff/kleanny @ rev 23641

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