LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-24-2014, 02:06 AM   #1
mr.simo
Member
 
Registered: Feb 2010
Posts: 78

Rep: Reputation: 0
Executing a task after the first update


Hi,

I need to update a Linux system and execute a task after a reboot.

The process is as follow:
  • 1) The updates are downloaded from a known URL in a specific folder.
  • 2) The machine is rebooted and during the startup, in a file placed in the properly rcN.d directory, the files are replaced with the older ones.

Basically, I have to change some permissions over the entire filesystem during the step 2.

I could place another file into the updates and successfully place it in the rcN.d directory but this will not be executed in step #2 but at the next reboot.

How can I solve my little problem ?

Thank you in advance.
 
Old 10-24-2014, 02:19 AM   #2
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Two ways come to my mind. You can use the rc.local file to do what you want after the reboot. You just have to remove the call to the update programm after its done its job.
Or you could use cron with the @reboot stanca. Heres a nice link: http://www.cyberciti.biz/faq/linux-e...system-reboot/
 
Old 10-24-2014, 03:23 AM   #3
mr.simo
Member
 
Registered: Feb 2010
Posts: 78

Original Poster
Rep: Reputation: 0
I solved including the permissions chmod and chown instructions into another shell script, let's call it file.sh.

Then I removed the chmod and chown lines from the same script with sed, inside the same file file.sh:

Code:
#!/bin/bash

# file.sh

chmod -R xxx /path/to/files
chown -R user:usergrp /path/to/files
sync

sed -i '/chown -R root:root/d' /path/to/file.sh
sed -i '/chmod/d' /path/to/file.sh
sed -i '/sync/d' /path/to/file.sh
sed -i '/sed/d' /path/to/file.sh
It works like a charm.


Last edited by mr.simo; 10-27-2014 at 04:57 AM.
 
Old 10-24-2014, 06:21 AM   #4
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
Nice work. So how do the call the script in the first place?
 
Old 10-25-2014, 05:51 AM   #5
mr.simo
Member
 
Registered: Feb 2010
Posts: 78

Original Poster
Rep: Reputation: 0
The script file.sh was already launched by default by another script in the rcN.d directory, let's call it S01xxx.

Another solution (avoiding to use a pre-existent script file.sh) is to substitute the same script S01xxx with another where the unique difference is to check if a particularly file file2.sh exists, and then execute it.. You can remove the same file2.sh by himself at the end of the file2.sh once it has executed one time..


Last edited by mr.simo; 10-25-2014 at 05:53 AM.
 
Old 10-27-2014, 03:11 AM   #6
zhjim
Senior Member
 
Registered: Oct 2004
Distribution: Debian Squeeze x86_64
Posts: 1,748
Blog Entries: 11

Rep: Reputation: 233Reputation: 233Reputation: 233
So the "usual" runlevel script approach. Good Job.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Python - Problems when trying to run a task at log on task on windows doomloard Programming 2 06-18-2011 04:31 PM
launching a task from cli and "divorcing it from terminal task wufo Linux - General 6 02-11-2011 11:32 AM
Probleme While executing apt-get update on Debian Etch Braveheart Killer Debian 1 08-23-2010 04:36 AM
Task bar no longer shows task Richard Rahl Linux - Newbie 3 04-12-2010 09:39 AM
Upgraded Firefox - How To Update Task Bar Link? GNewbie MEPIS 1 12-28-2005 12:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:12 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