homeclean: using set array, removed out-of-date content.

master
Pierre Neidhardt 2013-12-29 10:37:22 +01:00
parent a149d41ad8
commit e26d226c95
1 changed files with 41 additions and 57 deletions

View File

@ -1,42 +1,43 @@
#!/bin/sh
RMLIST="$HOME/.cache/dwb
$HOME/.cache/emacs
$HOME/.cache/mutt
$HOME/.cache/rtorrent
$HOME/.cache/zsh
$HOME/.cmus/autosave
$HOME/.cmus/cache
$HOME/.cmus/lib.pl
$HOME/.cmus/playlist.pl
$HOME/.cmus/queue.pl
$HOME/.cmus/resume
$HOME/.cmus/search-history
$HOME/.config/gtk-2.0
$HOME/.config/gtk-3.0
$HOME/.config/ranger/bookmarks
$HOME/.config/ranger/history
$HOME/.config/ranger/tagged
$HOME/.fehbg
$HOME/.gtk-bookmarks
$HOME/.lesshst
$HOME/.local/share/newsbeuter
$HOME/.local/share/webkit
$HOME/.mtap.fuseiso
$HOME/.pulse-cookie
$HOME/.viminfo
$HOME/.w3m
$HOME/.zcompdump"
set -- "$HOME/.cache/dwb" \
"$HOME/.cache/emacs" \
"$HOME/.cache/mutt" \
"$HOME/.cache/rtorrent" \
"$HOME/.cache/zsh" \
"$HOME/.cmus/autosave" \
"$HOME/.cmus/cache" \
"$HOME/.cmus/lib.pl" \
"$HOME/.cmus/playlist.pl" \
"$HOME/.cmus/queue.pl" \
"$HOME/.cmus/resume" \
"$HOME/.cmus/search-history" \
"$HOME/.config/gtk-2.0" \
"$HOME/.config/gtk-3.0" \
"$HOME/.config/ranger/bookmarks" \
"$HOME/.config/ranger/history" \
"$HOME/.config/ranger/tagged" \
"$HOME/.fehbg" \
"$HOME/.gtk-bookmarks" \
"$HOME/.lesshst" \
"$HOME/.local/share/newsbeuter" \
"$HOME/.local/share/webkit" \
"$HOME/.mpv/watch_later" \
"$HOME/.mtap.fuseiso" \
"$HOME/.pulse-cookie" \
"$HOME/.viminfo" \
"$HOME/.w3m" \
"$HOME/.zcompdump"
RMLIST_CRITICAL="
$HOME/.mutt.pwds.cpt
$HOME/.ssh"
## POSIX can store only one list at a time. Here we rely on the fact there is no
## space in the file names.
RMLIST_CRITICAL="$HOME/.mutt.pwds.cpt $HOME/.ssh"
echo "==> List of files to be removed."
echo "$RMLIST"
echo "$@" | sed 's/ /\n/g'
echo
echo "==> List of files to be wiped."
echo "$RMLIST_CRITICAL"
echo "$RMLIST_CRITICAL" | sed 's/ /\n/g'
CHOICE="N"
echo
@ -48,21 +49,6 @@ if [ "$CHOICE" != "Y" ]; then
exit
fi
## Delete git repo if any.
if [ -d "$HOME/.git" ]; then
echo
echo "==> Cleaning git repo."
rm -rf "$HOME/.git"
fi
## Delete Dropbox folder if any.
if [ -d "$HOME/Dropbox" ] || [ -d "$HOME/.dropbox" ]; then
echo
echo "==> Cleaning Dropbox folder."
rm -rvf "$HOME/Dropbox"
rm -rvf "$HOME/.dropbox"
fi
## Clean trash if possible.
echo
echo "==> Emptying trash."
@ -75,19 +61,17 @@ fi
## Remove data.
echo
while IFS= read -r i; do
rm -rvf "$i"
done <<EOF
$RMLIST
EOF
echo "==> Remove dotfiles."
rm -rvf "$@"
## Wipe data
echo
while IFS= read -r i; do
shred -zuv "$i"
done <<EOF
$RMLIST_CRITICAL
EOF
echo "==> Remove critical data."
if [ "$($HOME | grep -c' ')" -ne 0 ]; then
shred -zuv $RMLIST_CRITICAL
else
echo 'WARNING: $HOME contains spaces, skipping.'
fi
echo
echo "==> Cleaning done."