Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
Hello all,
I have a network with approximately 100 PCs running Ubuntu 8.04. All the PCs use autodir package because I need every user to be able to sit on any computer. Because we frequently add new users, we generate passwords, users and shadow files separately and on every boot those files are updated with rsync.
Unfortunatelly on some PCs this doesn't happen. On some of them it happens when the PC starts to shutdown, which is not a problem at all, but in case of new user the PC has to be restarted in order to receive those files.
The rc script has been generated with
Code:
update-rc.d syncronisation defaults
and it has created in all /etc/rcX.d files 20syncronisation
the script contains the following
Code:
rsync --delete --delete-after -v -r -z 172.23.31.16::muskogee /opt/remote
/opt/remote/init.sh //this replaces old passwords, shadows and users
How to make it to be executed on boot, not on shutdwon
And the other interesting thing is that if I put the script in rc.local it is not executed.
The scripts pointed to by /etc/rc[S0-6].d/S* symlinks are run on entering the associated run level. During boot, run level S is entered first, followed by whatever is set as your default run level. The default run level on ubuntu is 2 unless you have changed it.
What is the output from
Code:
/bin/ls -l /etc/rc[S0-6].d/*syncronisation*
What evidence do you have that your script is not being run during boot (as opposed to not doing what you intend it to do during boot)?
Links look fine. What evidence do you have that your script is not being run during boot (as opposed to not doing what you intend it to do during boot)?
First of all if the scripts are executed it could be seen in the boot process, since rsync copies 50 MB of files and the process is visible. The second is when new user is added, he cannot login before run the scripts manually or reboot and scripts are executed in the shutdown level 6. But this is not on all computes. The interesting thing is that there is no difference in computers because the installation is done using dd and disks are clones of one. I don't know really what is going on.
How to make it to be executed on boot, not on shutdwon
To runn at boot, you need only the /etc/rc2.d/S20syncronisation symlink; you can remove all the others. That presumes that your default run level is the original default, 2. You can test this by running
Code:
sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab
On an as-installed system this gives an error message
Code:
sed: can't read /etc/inittab: No such file or directory
In which case the default run level is 2. See the /etc/event.d/rc-default script.
This will also ensure that the script only does anything during boot; during shutdown it is called with $1 set to stop so does nothing.
It assumes your script is /etc/init.d/local_initialisation; adjust as appropriate.
BTW, // is not a bash script comment. In your original script "//this replaces old passwords, shadows and users" would have been passed to init.sh as arguments where they presumably (!) had no effect. The bash comment character is # as shown in the above example.
That will give you some messages on the console during boot so you can see if the script is being run. Once you have that information we can focus on either why it is not being run or why it is being run but is not doing what you want it to do.
Last edited by catkin; 08-25-2009 at 06:13 AM.
Reason: Typos
And the other interesting thing is that if I put the script in rc.local it is not executed.
That is interesting. We can have good confidence that rc.local is run so strange that the script is not run. Let's see what the suggested modified script tells us about whether it is being run or not.
Actually the script was placed in /opt directory and there was a link to it from /etc/rc2.d/S98syncronisation
In this manner it works on some computers.
Afterwards I put it in /etc/init.d and executed
update-rc.d syncronisation defaults
Two slashes do not reside in the script, I put them here in the post.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.