You are not logged in.
Pages: 1
Well, I have a project (I don't know if it exists for now...). I would want to create a program that does the following:
- The objetive of the script is to cleanup a system folder that you pass a parameter, i.e:
# ./cleanup-script /etc
This script will look recursively all files located at /etc, and it must do, for all files, the following command:
pacman -Qo $file
This command searches on your installed packages, who owns that file. If the filed is owned by any package, the file is not removed. If the file is not owned by anybody, the file is erased.
So, at the end of the execution, the /etc folder (in the example) will be cleaned up from all foreigner files that are not owned by anybody, having a cleaned system file.
Well, this is script will be dangerous: if we execute it on, for example, home folder, probably will delete all that folder!
Well, I am a noob on shell scripting. Is this script easy to make? Or is really harder to make? Does this script exists for now?
Greetings
Only deaths can see the end of battles.
Blog: http://djmartinez.co.cc -> The life of a Computer Engineer
Offline
Very raw and untested: (just a proof of concept)
#!/bin/bash
find $1 -type f -print0 -exec parseFile($1'{}') \;
function parseFile()
{
if [ $(pacman -Qo $1|cut -d':' -f2|cut -d's' -f1) = " No package own" ]; then
echo rm $1 permanently?
if [ $(read) =~ 'yes|YES|y|Y' ]; then
rm -r $1
fi
fi
}
Last edited by Ramses de Norre (2007-10-10 11:39:59)
Offline
This script will look recursively all files located at /etc, and it must do, for all files, the following command:
I am not sure that's a very efficient way to proceed.
I would rather do the following (only possible with pacman 3.1 though) :
# find /etc ! -type d | sort > filesystem-list
# pacman -Ql | cut -d' ' -f2 | grep "^/etc" | sort > package-list
$ diff filesystem-list package-list > result
For example, here are the files on filesystem but not in any packages :
$ cat result | grep "<" | sed -e "s/< //"
/etc/.pwd.lock
/etc/X11/xorg.conf
/etc/asound.state
/etc/fonts/conf.d/20-fix-globaladvance.conf
/etc/fonts/conf.d/20-lohit-gujarati.conf
/etc/fonts/conf.d/20-unhint-small-vera.conf
/etc/fonts/conf.d/30-amt-aliases.conf
/etc/fonts/conf.d/30-replace-bitmap-fonts.conf
/etc/fonts/conf.d/30-urw-aliases.conf
/etc/fonts/conf.d/40-generic.conf
/etc/fonts/conf.d/49-sansserif.conf
/etc/fonts/conf.d/50-user.conf
/etc/fonts/conf.d/51-local.conf
/etc/fonts/conf.d/60-latin.conf
/etc/fonts/conf.d/65-fonts-persian.conf
/etc/fonts/conf.d/65-nonlatin.conf
/etc/fonts/conf.d/69-unifont.conf
/etc/fonts/conf.d/80-delicious.conf
/etc/fonts/conf.d/90-synthetic.conf
/etc/group-
/etc/gshadow-
/etc/gtk-2.0/gdk-pixbuf.loaders
/etc/gtk-2.0/gtk.immodules
/etc/ld.so.cache
/etc/localtime
/etc/mtab
/etc/network-profiles/maison
/etc/pango/pango.modules
/etc/passwd-
/etc/profile.d/locale.sh
/etc/shadow-
/etc/xml/catalog
I don't think any of these files are wrong. Most of them belong there.
For example, backup files : group- , gshadow- , shadow-, passwd-
custom config files : xorg.conf, network profile
all font config files in /etc/fonts/conf.d/ are just symlinks, which can be added / removed by the user for configuring.
other files created at run time of some apps : .pwd,lock , asound,state , ld.so.cache, localtime, mtab
I don't think it would be wise removing all of them.
pacman roulette : pacman -S $(pacman -Slq | LANG=C sort -R | head -n $((RANDOM % 10)))
Offline
Pages: 1