[SOLVED] Slackware(64) 15.0 - /etc/rc.d/rc.local is not working
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Slackware(64) 15.0 - /etc/rc.d/rc.local is not working
Hi there, for unknow reasons this is not working during boot. the current content /etc/rc.d/rc.local file are the follow :
Code:
#!/bin/bash
#
# /etc/rc.d/rc.local: Local system initialization script.
#
# Put any local startup commands in here. Also, if you have
# anything that needs to be run at shutdown time you can
# make an /etc/rc.d/rc.local_shutdown script and put those
# commands in there.
echo 'Ejecutando : /etc/rc.d/rc.local'
# Sincronizar Hora al Iniciar el Sistema :
echo 'Sincronizar Hora'
ntpdate=$(whereis -B "/usr/sbin" "/usr/local/sbin" "/sbin" "/usr/bin" "/usr/local/bin" "/bin" -b ntpdate | grep -i "ntpdate" | cut -d " " -f02 | cut -c11-20)
service=$(whereis -B "/usr/sbin" "/usr/local/sbin" "/sbin" "/usr/bin" "/usr/local/bin" "/bin" -b service | grep -i "service" | cut -d " " -f02 | cut -c11-20)
rcntpd="/etc/rc.d/rc.ntpd"
if [ -z "$ntpdate" ]; then
echo
echo "ntpdate no esta instalado en tu sistema operativo GNU"
echo "Por favor, primero instale : ntpdate"
echo
exit 0
fi
if [ -d "/etc/rc.d" ];then
if [ -f "$rcntpd" ]; then
chmod +x "$rcntpd"
2>/dev/null 1>/dev/null "$rcntpd" "stop" &> /dev/null
#rm "/etc/localtime"
#ln -sf "/usr/share/zoneinfo/America/Caracas" "/etc/localtime"
#echo ""
CloudFlare=$(ping -c 1 1.1.1.1 | sed -n '5p' | cut -c 24-33)
if [ "$CloudFlare" == "1 received" ]; then
2>/dev/null 1>/dev/null "ntpdate" "pool.ntp.org" &> /dev/null
sleep 3
hwclock -w
fi
2>/dev/null 1>/dev/null "$rcntpd" "start" &> /dev/null
echo ""
fi
fi
#Montar Carpeta Compartida mediante el Protocolo CIFS :
echo 'Montar la Carpeta Compartida (CIFS, NO SMB) :'
CarpComp=$(ping -c 1 10.48.1.220 | sed -n '5p' | cut -c 24-33)
if [ "$CarpComp" == "1 received" ]; then
mkdir -p /media/Tecnologia
mkdir -p /media/Soporte
$(mount -t cifs //10.48.1.220/Tecnologia /media/Tecnologia -o username=user,password=us3rp4ssw0rd,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=FUNDAPROAL) &
$(mount -t cifs //10.48.1.220/Soporte /media/Soporte -o username=user,password=us3rp4ssw0rd,uid=1000,gid=1000,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777,domain=FUNDAPROAL) &
fi
if [ -x /etc/rc.d/rc.qemu-ga ]; then
# Start QEMU Guest Agent:
echo "Starting QEMU Guest Agent: /etc/rc.d/rc.qemu-ga start"
/etc/rc.d/rc.qemu-ga start
fi
After i write all things i want inside that file i use the follow commands :
su -c "chmod 755 /etc/rc.d/rc.local ; chmod +x /etc/rc.d/rc.local" root
- Ask for the password, i put and press enter
- i restart the system, and is not working.
The current Desktop Env i am using is : KDE Plasma.
Try running it by hand (/etc/rc.d/rc.local) and see if it runs properly. If it does, then probably it's not being called in the startup scripts. I have it being called from rc.M. Check that it's being called.
Is /etc/rc.d/rc.ntpd set to 755 ?
I am not sure, if it executable by Default after Installation or must be set explicitely
ntpdate should be /usr/sbin/ntpdate
When one of my new shell scripts fail and I can't see anything obvious, I insert an exit command at various points of the script. Then manually launch the script. If the script functions correctly then I move the exit command further down. Eventually I find where the script fails.
Others have already mentioned some obvious self-checks.
At least the lines with $(mount ...) look strange. 'mount ...' would do the mount. $(mount ...) is the output of the mount command. If the command is that alone, you try to execute the output of the mount command.
Not sure what is up with all the redirects. Just use "$rcntpd" "stop" > /dev/null 2>&1
If ntpdate is not installed the script exits. Is it installed on this system?
The ntp startup script uses the -g option which is the same thing as running ntpdate. If the network is up and connected it makes this entire if section redundant.
As suggested you do not need to put the mount command between $().
Are you sure the network is up at this time? How are you starting it? Something like networkmanager can take longer to bring the interface up than it takes for rc.local to finish. If your single ping doesn't succeed then nothing else will happen afaict.
The script is hard to read with many levels of redundancy as others mention. Also I dont understand why go to the trouble of setting rc.ntpd executable and toggling the service off/on at every boot when its already coded into the rc.M script and just needs to be enabled once when you first configure the installation.
Something like autofs might be worth looking at if you want to automatically mount some network shares. I use it with nfs shares. Haven't looked into setting it up with samba/cifs but it looks like its supported.
Try running it by hand (/etc/rc.d/rc.local) and see if it runs properly. If it does, then probably it's not being called in the startup scripts. I have it being called from rc.M. Check that it's being called.
yes when i run it manually works fine
Quote:
Which part fails? Where does it stop?
Try booting to run level 3 to see the output from your commands.
In "ping" during boot the network access is not ready at that point
Quote:
In your console output, does the script get as far as printing "Ejecutando : /etc/rc.d/rc.local"?
Yes, but i dont notice until now.
Quote:
Is /etc/rc.d/rc.ntpd set to 755 ?
I am not sure, if it executable by Default after Installation or must be set explicitely
ntpdate should be /usr/sbin/ntpdate
in the script the right path is solve by this command
In "ping" during boot the network access is not ready at that point
How did you configure your network? If done the good old way with /etc/rc.d/rc.inet1 and settings in /etc/rc.d/rc.inet1.conf your network should be up and running before reaching rc.local. However, there are many ways to do things, sometimes laptops are configured to get their network settings manully by the user after the user has been logged in.
If you want your network to be up when rc.local is run you can not rely on any manual steps from a user logged in.
You have reported that the ping failed. Which ping?
It might be helpful to put "/sbin/ifconfig" near the top of rc.local.
Then compare its output to the same command "/sbin/ifconfig" when you run it later.
How did you configure your network? If done the good old way with /etc/rc.d/rc.inet1 and settings in /etc/rc.d/rc.inet1.conf your network should be up and running before reaching rc.local. However, there are many ways to do things, sometimes laptops are configured to get their network settings manully by the user after the user has been logged in.
If you want your network to be up when rc.local is run you can not rely on any manual steps from a user logged in.
regards Henrik
With NetworkManager, i need configure the Cisco Switch to use the MAC to get a static ip exclusive for my pc, because the internal DHCP server every time i restart, change the ip.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.