Jump to content

accidentally lost rc.local


Guest bonzai
 Share

Recommended Posts

While trying to add a few route add's to my rc.local file via WinSCP, this program crashed and when I reconnected rc.local was completely empty !

Is there a way to recreate this file and have full functionality again after reboot ? I have a backup from 2 months ago, would it be safe to use that one or would I lose some stuff?

I'm a little desperate to know what's best here...

All help welcome...thx

 

 

 

 

Moved from Software to Terminal Shell Commands, Kernel & Programming - Artificial Intelligence

Edited by Artificial Intelligence
Link to comment
Share on other sites

Here's mine which has not been edited in any way:

 

#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

[ -f /etc/sysconfig/system ] && source /etc/sysconfig/system
[ -f /etc/sysconfig/msec ] && source /etc/sysconfig/msec
[ -z "$SECURE_LEVEL" ] && SECURE_LEVEL=3
[ -f /etc/sysconfig/init ] && source /etc/sysconfig/init
if [ $SECURE_LEVEL -lt 4 ]; then
   [ -z "$REWRITEISSUE" ] && REWRITEISSUE=rewrite
   if [ $SECURE_LEVEL -lt 3 ]; then
[ -z "$REWRITEISSUENET" ] && REWRITEISSUENET=rewrite
   fi
fi

SYSTEM=${SYSTEM=Mandrakelinux}

# Source functions
. /etc/init.d/functions

if [ "$REWRITEISSUE" = "rewrite" -a -f /etc/mandrake-release ]; then
   R=$(cat /etc/mandrake-release)

   arch=$(uname -m)
   a="a"
   case "_$arch" in
    _a*) a="an";;
    _i*) a="an";;
   esac
   
   NUMPROC=`egrep -c "^cpu[0-9]+" /proc/stat`
   if [ "$NUMPROC" -gt "1" ]; then
       SMP="$NUMPROC-processor "
[ "$NUMPROC" = "2" ] && \
SMP="Dual-processor "
       if [ "$NUMPROC" = "8" -o "$NUMPROC" = "11" ]; then
           a="an"
else
    a="a"
       fi
   fi

   # This will overwrite /etc/issue at every boot.  So, make any changes you
   # want to make to /etc/issue here or you will lose them when you reboot.

   if [ -x /usr/bin/linux_logo ]; then
/usr/bin/linux_logo -n -f | sed -e 's|\\|\\\\|g' > /etc/issue
echo "" >> /etc/issue
   else
> /etc/issue
   fi
   echo "$R" >> /etc/issue
   echo "Kernel $(uname -r) on $a $SMP$(uname -m) / \l" >> /etc/issue
   
   if [ "$REWRITEISSUENET" = "rewrite" ]; then
echo "Welcome to ${HOST}" > /etc/issue.net
echo "$R" >> /etc/issue.net
echo "Kernel $(uname -r) on $a $SMP$(uname -m)" >> /etc/issue.net
   else
NAME="$SYSTEM"
gprintf "Welcome to %s\n" "$NAME" > /etc/issue.net
echo "-------------------------" >> /etc/issue.net
   fi
else
   if [ -f /etc/security/msec/issue.$SECURE_LEVEL ]; then
cat /etc/security/msec/issue.$SECURE_LEVEL > /etc/issue
   elif [ -f /etc/security/msec/issue ]; then
cat /etc/security/msec/issue > /etc/issue
   else
rm -f /etc/issue
   fi
   if [ -f /etc/security/msec/issue.net.$SECURE_LEVEL ]; then
cat /etc/security/msec/issue.net.$SECURE_LEVEL > /etc/issue.net
   elif [ -f /etc/security/msec/issue.net ]; then
cat /etc/security/msec/issue.net > /etc/issue.net
   else
rm -f /etc/issue.net
   fi
fi

touch /var/lock/subsys/local

Link to comment
Share on other sites

yes, it is perfectly safe to use your rc.local backup copy. But if you want to use the default one you can find it in initscripts rpm package (1). rc.local is a file that usually isn't modify often.

 

(1) Here is a way to extract that file w/o having to reinstall the full rpm package:

~$ rpm2cpio ftp://WHATEVER_RPM_MIRROR/initscripts-your_version.rpm |cpio -idv rc.local && cp -i ./etc/rc.local /etc

In the example, I'm using a rpmpackage from the net, but you may have your own mdk-CDROM at hand.

 

HTH

 

oops, pmpatrick you were faster ;)

Link to comment
Share on other sites

(1) Here is a way to extract that file w/o having to reinstall the full rpm package:

~$ rpm2cpio ftp://WHATEVER_RPM_MIRROR/initscripts-your_version.rpm |cpio -idv rc.local && cp -i ./etc/rc.local /etc

In the example, I'm using a rpmpackage from the net, but you may have your own mdk-CDROM at hand.

[...]

 

[offtopic]The trick, if any is inerested could be something like this (I believe I posted it somtime ago in tips&tricks):

rpm_fastextr () {
   # usage: rpm_fastextr fullpath/rpmpackage filetoextract
   local rpm_pkg="$1" file="$2" timeout=${3:-10}
   rpm2cpio $rpm_pkg | cpio -idv "*${file}" 2>&1 | tee rpm2cpio.out & while :; do
       if grep "${file}"; then
           sleep $timeout;
           killall rpm2cpio;
           break;
       else
           sleep 2;
       fi;
   done
}

Using it you'll ensure that rpm2cpio stops just after finding the file you want and don't parses the full rpm package.

[/offtopic]

 

PS sorry for this off-topic :screwy:

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...