LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-29-2005, 03:46 AM   #1
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Rep: Reputation: 50
Looking for scripts to help fix my mistake


I messed up BIG today.

What I wanted to type was:

Code:
rm -r usr
But what I typed instead was:

Code:
rm -r /usr
Luckily, I "ctrl-c"d it after ~2 min.

Through some (what I thought was) clever thinking on my part, I managed to get my system back up and running.

Now, I want to verify that everything is really fixed. I am looking for two scripts (which are, in essence, corrollaries of each other.

Script 1:

I am looking for a script that will parse /var/log/packages for installed files and tell me if a file that should be installed is missing.

Script 2:

I am looking for a script that will parse /var/log/packages and tell me which files are orphans (i.e. they don't belong to any package). This script could/should probably ignore /home, /root, and /tmp. It should also probably avoid some other things (/var?).

For my purposes, such a script would only need to deal with /usr . But I was thinking that two scripts like these would probably be pretty handy for a SLackware admin in general. I'm hoping that aomething like these already exists. If not, this might be a good place to flesh something like that out.

I think these scripts (if they don't already exist) would make good additions to the Slackware package management tools. They could help out when doing major system upgrades.

A bit OT (in my own post, no less), here is some info on what I have done so far to remedy my huge mistake.

Some info:

My system:

Fresh Slackware 10.2: Full Install

Upgraded to -current via SWareT (not a huge issue at this point, since there have been very few changes to -current since the SLackware 10.2 release)

Dropline 2.12.1 (always kept current via the dropline-installer): Full install

Several self compiled packages (all made with SlackBuild scripts)

Only one third-party package (SWareT)

LOTS of separate partitions. Fortunately, I had set aside one 10G partition

How I "fixed" my system so far:

First up, I installed a fresh Slackware 10.2 on my spare partition

Next, I copied all of the new /usr to the old /usr. I used "cp" with the Recursive option and the Interactive option. The Recursive option made sure I got everything. The Interactive option made sure I didn't overwrite anything. For those unfamiliar with the Interactive option (-i), it asks before overwriting a pre-existing file. I figured out that just pressing enter was the same as "n", at which point I wedged something in my keyboard and made a snack. My thinking here was that I wanted to copy over files that I was missing. If the files hadn't been deleted, no need to mess with them.

I later thought that I probably should have specified teh -a option (to retain permissions). But I then thought that it really didn't matter, since Slackware tends to create anything under /usr as root.root.

That should have solved my issues with having Slackware 10.2 installed.

Next, I wanted to make sure I was A-OK wit hmy updates to -current. I issued the following commands:

Code:
cd /var/swaret
upgradepkg --reinstall *.tgz
That should have taken care of my Slackware -current installation.

Next up was Dropline. First, I used "upgradepkg --reinstall" for the dropline-installer. Then I realized tha tthe dropline installer would think everything was already peachy-keen. So I did the following:

Code:
cd /var/log/packages
rm *dl
Then I ran the dropline-installer. Things were not all smooth. The X11 font packages would not install (they would crash the dropline-installer. I realized tha tthis was due to differences in Dropline's X11 packages. Knowing that, I copied all the X11 files from the new /usr to the old /usr. I then used pkgtool to remove all of them (knowing that all files which were also contained in a Dropline X11 package would be left alone). This worked beautifully, and I was able to complete my Dropline install afterwards with no issues.

At this point, I used "upgradepkg --reinstall" to re-install SWareT. THis was mainly so I could check out things with the following commands:

Code:
updatedb
swaret --dep
This let me know tha I wasn't missing any dependencies for my installed programs.

Next, I rebuilt all of /usr/src with my custom kernels. Luckily, I save my configs on a separate partition.

The final step was to re-install my custom packages (just to be sure everything is working). I am still on that step, but I don't forsee any problems .

So wha tis left that may be an issue? The only thing I can think of right now is the packages thatDropline removes from a stock 10.2 install. That shouldn't be too much trouble. Other than that, I am hoping that the scripts that I described earlier already exist. THis would confirm that EVERYTHING is back to normal.

Last edited by shilo; 10-29-2005 at 03:47 AM.
 
Old 10-29-2005, 04:48 AM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Re: Looking for scripts to help fix my mistake

Quote:
Originally posted by shilo
Script 1:

I am looking for a script that will parse /var/log/packages for installed files and tell me if a file that should be installed is missing.
Code:
#!/bin/bash
# package-health-check ... whipped up for shilo :)
cd /var/log/packages
for i in `ls -1`
do
  for j in `awk '!/install\// &&  !/^\./ && !/:/ && /\// {print "/"$0}' $i`
  do
    if [ ! -e $j ]; then
      echo $j "missing"
    fi
  done
done
Should do the trick


Quote:
Originally posted by shilo
Script 2:

I am looking for a script that will parse /var/log/packages and tell me which files are orphans (i.e. they don't belong to any package). This script could/should probably ignore /home, /root, and /tmp. It should also probably avoid some other things (/var?).

For my purposes, such a script would only need to deal with /usr :). But I was thinking that two scripts like these would probably be pretty handy for a SLackware admin in general. I'm hoping that aomething like these already exists. If not, this might be a good place to flesh something like that out.
Code:
#!/bin/bash
# orphan-check ... whipped up for shilo :)
#for i in `locate .|sed 's@^/@@'|egrep -v "(/root|/home|/tmp)"`
for i in `locate . |sed 's@^/@@'|egrep -v "(/root|/home|/tmp)"`
do
  if grep "$i" /var/log/packages/*  2>&1 >/dev/null
      then echo "potential orphan: "$i 
  fi
done
Number two should work to, I didn't bother with proper quoting, though.


Cheers,
Tink
 
Old 10-29-2005, 10:02 AM   #3
shilo
Senior Member
 
Registered: Nov 2002
Location: Stockton, CA
Distribution: Slackware 11 - kernel 2.6.19.1 - Dropline Gnome 2.16.2
Posts: 1,132

Original Poster
Rep: Reputation: 50
WHOO-WHOO!

THANK YOU, TINKSTER!!!
 
Old 10-29-2005, 02:49 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: earth
Distribution: slackware by choice, others too :} ... android.
Posts: 23,067
Blog Entries: 11

Rep: Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928Reputation: 928
Quote:
Originally posted by shilo
WHOO-WHOO!

THANK YOU, TINKSTER!!!
You're welcome ;}


Cheers,
Tink
 
Old 10-30-2005, 05:20 AM   #5
PDock
Member
 
Registered: Aug 2004
Distribution: Slack10 & curr. tried numerous
Posts: 189

Rep: Reputation: 37
WHOO-WHOO!

THANK YOU, TINKSTER!!!

a cheap addition/change
Code:
#!/bin/bash
# package-health-check ... whipped up for shilo :)
cd /var/log/packages
for i in `ls -1`
do
  for j in `awk '!/install\// &&  !/^\./ && !/:/ && /\// {print "/"$0}' $i`
  do
    if [ ! -e $j ]; then
      echo $j "missing from: "$i
    fi
  done
done
ppd
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
VPN: Debian Scripts -> Mandriva 2006 Scripts Undefined Mandriva 0 11-30-2005 12:10 PM
all attempts to fix the problem failed... can someone help me fix partition space? foreverdita Linux - Enterprise 2 05-11-2005 09:02 AM
My mistake (rm in /dev) erickFis Linux - Newbie 2 02-27-2004 06:29 AM
Mistake Compiling 2.6.0 Inexactitude Linux - Hardware 7 01-11-2004 05:25 PM
Linux Mandrake 8.0 -- HELP I made a mistake during install and don't know how to fix! Avatar Linux - Software 9 07-27-2001 10:30 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 06:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration