Click here to Skip to main content
16,020,378 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am creating a linux init script to copy some files from my pen drive to my raspberry system drive. but its not copying the files from pen drive to system on booting time. but when i executed it from terminal its working fine.

PERL
for PENDRIVE in /media/*
	do
		
		if [ -d "$PENDRIVE/Update" ]; then
			INSTALLDIR="$PENDRIVE/Update"
			cp -r $INSTALLDIR /tmp/
			
			chmod a+x /tmp/Update/install.sh
			
			/tmp/Update/install.sh /tmp/Update
		fi
	done



I tried to edit in rc.local too. But it shows the error cannot find the file to copy...
Posted
Comments
Richard MacCutchan 4-Jul-13 3:56am    
You need to ensure that this script does not run until all the drives are mounted. Check the man pages for init to see which phase to use.
Arun Kumar K S 4-Jul-13 4:09am    
I put the script in rc.local. rc.local is the last executing script
Richard MacCutchan 4-Jul-13 4:31am    
Well you still need to check that the drive is actually mounted at that time.
Arun Kumar K S 4-Jul-13 4:38am    
Please bare with me if the question is simple because I am a windows programmer, I am not that much familiar with shell scripting. how I can check this with scripting? and how I can wait for finish mounting?
Richard MacCutchan 4-Jul-13 4:42am    
I'm not sure of the answer I'm afraid, it is some years since I worked on Linux, but the man pages are the best place to look.

1 solution

I've run into this type of problem as well and I have identified 2 things that I have to fix:

(1) file/directory protection versus username during boot process ... solution I think is obvious
(2) during the boot process, a lot of things run before all disks are mounted. Make sure that the code above runs after the USB drives are mounted. At least for debugging purposes, add logging info to your code to tell if the USB drive is mounted. You might find that this happens quite late in the boot process.
 
Share this answer
 
Comments
Arun Kumar K S 8-Jul-13 1:46am    
But how? I tried the script in rc.local but the disk is mounting after the rc.local
H.Brydon 8-Jul-13 13:06pm    
Try putting your code in /etc/rcS.d and set it up to run last (eg. S90CopyFiles).
Arun Kumar K S 9-Jul-13 1:21am    
I will try it and I think rc.local will be run after run-level specific commands whenever the system is booted.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900