LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 01-23-2024, 01:28 PM   #1
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 271

Rep: Reputation: 26
Question 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.

What i am doing wrong ?
 
Old 01-23-2024, 01:38 PM   #2
jayjwa
Member
 
Registered: Jul 2003
Location: NY
Distribution: Slackware, Termux
Posts: 779

Rep: Reputation: 246Reputation: 246Reputation: 246
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.
 
Old 01-23-2024, 01:46 PM   #3
rwm_lq
LQ Newbie
 
Registered: Aug 2022
Distribution: Slackware
Posts: 4

Rep: Reputation: 0
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

Last edited by rwm_lq; 01-23-2024 at 01:49 PM.
 
Old 01-23-2024, 02:39 PM   #4
lostintime
Member
 
Registered: Dec 2021
Posts: 192

Rep: Reputation: Disabled
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.
 
2 members found this post helpful.
Old 01-23-2024, 04:27 PM   #5
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 365

Rep: Reputation: 171Reputation: 171
In your console output, does the script get as far as printing "Ejecutando : /etc/rc.d/rc.local"?
 
1 members found this post helpful.
Old 01-26-2024, 09:18 PM   #6
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,453
Blog Entries: 7

Rep: Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556Reputation: 2556
Which part fails? Where does it stop?

Try booting to run level 3 to see the output from your commands.

My first tip is that doing 'chmod +x' after 'chmod 755' is redundant.
 
Old 01-27-2024, 02:43 AM   #7
Petri Kaukasoina
Senior Member
 
Registered: Mar 2007
Posts: 1,791

Rep: Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470Reputation: 1470
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.
 
Old 01-27-2024, 07:15 AM   #8
keefaz
LQ Guru
 
Registered: Mar 2004
Distribution: Slackware
Posts: 6,552

Rep: Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872Reputation: 872
Not sure you need so many tests...
Quote:
Code:
if [ -d "/etc/rc.d" ];then
It's obvious rc.d exists at this point, no? (code executed from /etc/rc.d/rc.local file)
 
Old 01-27-2024, 07:59 AM   #9
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,714

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
Quote:
2>/dev/null 1>/dev/null "$rcntpd" "stop" &> /dev/null
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 $().
 
Old 01-27-2024, 08:34 AM   #10
0XBF
Member
 
Registered: Nov 2018
Distribution: Slackware
Posts: 766

Rep: Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867Reputation: 867
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.

Last edited by 0XBF; 01-27-2024 at 08:40 AM.
 
Old 01-30-2024, 11:37 AM   #11
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 271

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by jayjwa View Post
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
Code:
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)
 
Old 01-30-2024, 12:13 PM   #12
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,714

Rep: Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899Reputation: 5899
What type of ISP? Do you use a VPN service? When you run the script manually the network is up and the script works fine?

Basically if ntpdate is installed it will located in /usr/sbin so whereis is not necessary.
 
Old 01-30-2024, 12:30 PM   #13
henca
Member
 
Registered: Aug 2007
Location: Linköping, Sweden
Distribution: Slackware
Posts: 961

Rep: Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649Reputation: 649
Quote:
Originally Posted by inukaze View Post
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.

regards Henrik
 
Old 01-30-2024, 03:39 PM   #14
metaed
Member
 
Registered: Apr 2022
Location: US
Distribution: Slackware64 15.0
Posts: 365

Rep: Reputation: 171Reputation: 171
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.
 
Old 01-30-2024, 03:49 PM   #15
inukaze
Member
 
Registered: Feb 2011
Location: Venezuela - Caracas
Distribution: Slackware64 14.2, Slackware 14.2, Gentoo, Devuan, gNewSense, GoboLinux, Leeenux, Porteus
Posts: 271

Original Poster
Rep: Reputation: 26
Quote:
Originally Posted by henca View Post
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.

I make a internal NTP server with ip 10.48.1.38

Last edited by inukaze; 01-30-2024 at 03:52 PM.
 
  


Reply

Tags
rc.local, slackware64 15.0



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
What are the best ways and practices to manage local SSL certificates with my own CA, to get local HTTPS sites like https://testsite.local ? ZhaoLin1457 Slackware 11 02-04-2021 04:15 PM
sudo and su - both are not working as i have removed my local user from local group RonakChauhan Linux - Newbie 4 05-18-2020 08:48 PM
[SOLVED] /etc/rc.d/rc.local vs /usr/local/share Lysander666 Slackware 4 11-16-2018 03:28 PM
Why and how settings of mounting NFS in /etc/rc.local are overrided with /etc/fstab? yglin Linux - Newbie 7 04-30-2014 05:40 AM
What is the difference between /etc/init.d/boot.local and /etc/rc.d/boot.local..? mozart Linux - Newbie 3 06-13-2007 06:50 PM

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

All times are GMT -5. The time now is 06:43 PM.

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