LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Question on script for .new files from UPGRADE.TXT (http://www.linuxquestions.org/questions/slackware-14/question-on-script-for-new-files-from-upgrade-txt-642402/)

Lufbery 05-15-2008 10:20 AM

Question on script for .new files from UPGRADE.TXT
 
Hi all,

I'm upgrading Slackware from 12 to 12.1 and things have gone pretty well. I'm at the point where I need to work with the .new configuration files and I've got a question.

The UPGRADE.TXT file says:

Quote:

Fix your config files. Some of the config files in /etc are going to need your attention. You'll find the new incoming config files on your system with the ".new" extension. You may need to fill these in with information from your old config files and then move them over.

Feel brave? You can use this little script to install all of the .new config files in /etc. If you've made any local changes you'll need to add them to the newly installed files. Your old config files will be copied to *.bak. Anyway, it might be an easier starting point. Here it is:

Code:

  #!/bin/sh
  cd /etc
  find . -name "*.new" | while read configfile ; do
    if [ ! "$configfile" = "./rc.d/rc.inet1.conf.new" \
    -a ! "$configfile" = "./group.new" \
    -a ! "$configfile" = "./passwd.new" \
    -a ! "$configfile" = "./shadow.new" ]; then
    cp -a $(echo $configfile | rev | cut -f 2- -d . | rev) \
      $(echo $configfile | rev | cut -f 2- -d . | rev).bak 2> /dev/null
    mv $configfile $(echo $configfile | rev | cut -f 2- -d . | rev)
    fi
  done


My script-reading skills are still pretty shaky. Does this script just move the rc.inet1.conf, group, passwd, and shadow files, or does it NOT move those files?

Will this script find all the .new files and install them?

In short, what exactly does this script do?

Thanks,

-Drew

jong357 05-15-2008 10:28 AM

if [ ! "$configfile" = "./rc.d/rc.inet1.conf.new" \
-a ! "$configfile" = "./group.new" \
-a ! "$configfile" = "./passwd.new" \
-a ! "$configfile" = "./shadow.new" ]; then

Basically it reads:

if whatever.new doesn't equal group, passwd, shadow or rc.inet1.conf then give the originals a .bak extension and then rename the new ones so they don't have a .new extension.

So it leaves those for your manual attention. The "!" is telling it to exclude those files. Remove that and then it will only handle those files.

jong357 05-15-2008 10:40 AM

Try adding a verbose switch to the mv command before you run it. Would be better to actually see what's going on IMO.

mv -v $configfile $(echo $configfile | rev | cut -f 2- -d . | rev)

jong357 05-15-2008 10:57 AM

Code:

#!/bin/sh
  cd /etc
  find . -name "*.new" | while read configfile ; do
    if [ ! "$configfile" = "./rc.d/rc.inet1.conf.new" \
    -a ! "$configfile" = "./group.new" \
    -a ! "$configfile" = "./passwd.new" \
    -a ! "$configfile" = "./shadow.new" ]; then
    cp -a $(echo $configfile | rev | cut -f 2- -d . | rev) \
      $(echo $configfile | rev | cut -f 2- -d . | rev).bak 2> /dev/null
    mv -v $configfile $(echo $configfile | rev | cut -f 2- -d . | rev)
    else
    echo "$configfile needs your manual attention..."
    fi
  done

That would be a "better" (more informative) script....

Lufbery 05-15-2008 11:30 AM

Jong,

Thanks for the reply. The gist is that the script leaves the four named configuration files alone and handles the rest.

Thanks!

I'll make the "verbose" change, run it, and see what happens.

Regards,

-Drew

T3slider 05-15-2008 01:20 PM

You should also note that if you made any changes to the original 12.0 files, you will have to add those changes to the new 12.1 files. After running that script, the 12.1 config files will have the proper names and your 12.0 files will have *.bak names -- you can look through the .bak files (`find /etc -name *.bak` should show you all of the .bak files created) and add your changes to the new files (without the .bak extensions).

Lufbery 05-15-2008 01:59 PM

Quote:

Originally Posted by T3slider (Post 3154356)
You should also note that if you made any changes to the original 12.0 files, you will have to add those changes to the new 12.1 files. After running that script, the 12.1 config files will have the proper names and your 12.0 files will have *.bak names -- you can look through the .bak files (`find /etc -name *.bak` should show you all of the .bak files created) and add your changes to the new files (without the .bak extensions).

Thanks. I figured that was the point, but I was worried that the group, shadow, and passwd files would be changed.

When I add things to my configuration files, I usually put in a comment like:

## Added by me

That makes is a lot easier to see what I changed.

Regards,

-Drew

shadowsnipes 05-15-2008 02:11 PM

You might also want to read HowTo Upgrade Slackware 12.0 to 12.1 and pay particular attention to the notes about the config files (such as those under /etc/modprobe.d).

stu_mueller 05-15-2008 03:06 PM

Sorry to butt in on this thread, but I have a question that seems relevant.

The passwd and group files have users and groups that you have created, how should these be handled when you upgrade. should the passwd.new be renamed to passwd, and any users you setup in your original passwd file just be copied over to the new passwd file?

Thats what I did on my upgrade but I'm not sure if thats right. It seems to have worked

Stuart

shadowsnipes 05-15-2008 03:46 PM

Quote:

Originally Posted by stu_mueller (Post 3154451)
Sorry to butt in on this thread, but I have a question that seems relevant.

The passwd and group files have users and groups that you have created, how should these be handled when you upgrade. should the passwd.new be renamed to passwd, and any users you setup in your original passwd file just be copied over to the new passwd file?

Thats what I did on my upgrade but I'm not sure if thats right. It seems to have worked

Stuart

From my upgrade HowTo
Quote:

/etc/group.new → Remove
/etc/passwd.new → Remove
/etc/shadow.new → Remove
/etc/gshadow.new → Remove
The new group and passwd files would only be useful if there were some new groups or users needed for some new feature, and something like that would have been mentioned in CHANGES_AND_HINTS.TXT. It wasn't so they were removed promptly.


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