WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Permanent disable DHCP + run script at startup  (Read 12639 times)

Offline personage

  • Newbie
  • *
  • Posts: 6
Permanent disable DHCP + run script at startup
« on: June 03, 2010, 05:35:59 PM »
I'm working on a customized version of microcore-current, but have ran into problems.
I want the OS to:
1) Permanently skip setting up network (as I won't need it, ever)
2) Run a script when startup is finished.

1)
So basically I've followed the Remaster-guide from wiki, and it seems like I want to edit /etc/init.d/tc-config, right? But I can't understand which part I'll have to delete to skip the network-configuration during boot.

2)
I would probably need to use a cron-job here, right? But where to put the script in that case?
The script looks like this:
Code: [Select]
#!/bin/bash
sudo su
cd /home/tc
dd if=/dev/sda of=mbr.backup bs=446 count=1
md5sum -c mbr.backup md5.txt
I need to view the output, so it can't be hidden in the background.

Offline danielibarnes

  • Hero Member
  • *****
  • Posts: 548
Re: Permanent disable DHCP + run script at startup
« Reply #1 on: June 03, 2010, 06:53:56 PM »
1) You need to prevent dhcp.sh from running. Three solutions:
1.1) The most common way to do this is with the "nodhcp" boot parameter.
1.2) Set NODHCP=1 at the beginning of /etc/init.d/tc-config and remaster.
1.3) To avoid remastering, replace /etc/init.d/dhcp.sh with an empty script in a backup file.

2) No cron job needed. The /opt/bootlocal.sh is executed in the background at the end of /etc/init.d/tc-config. Two solutions:
2.1) Remove the '&' at the end of the "/opt/bootlocal.sh &" line in /etc/init.d/tc-config. It will then run in the foreground.
2.2) To avoid remastering, you could add code to /root/.profile and put that file in your backup.

There are other ways as well, depending on what you are trying to do.

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Permanent disable DHCP + run script at startup
« Reply #2 on: June 03, 2010, 06:54:33 PM »
1. Add the 'nodhcp' boot option.
2. Add your script to /opt/bootlocal.sh

Offline personage

  • Newbie
  • *
  • Posts: 6
Re: Permanent disable DHCP + run script at startup
« Reply #3 on: June 04, 2010, 04:30:13 PM »
1) I made an empty /etc/init.d/dhcp.sh, and it works like a charm, so thanks for the quick replies.

2) This is however still bothering me. I've placed the script in /opt/bootlocal.sh and have removed the "&" after the line in tc-config, but the script refuses to run.

I tried the following command, just to see whether the script could run manually on TC/MC or not, and it seems like a no-go, but why?
Code: [Select]
$ sudo su
# cd /opt
# ./bootlocal.sh
sh: ./bootlocal.sh: not found
Then I used the ls-command to verify, that the script actually existed in /opt, and it did.
I've done chmod u+x before I moved the script to /opt from my native system (Ubuntu)


Current /opt/bootlocal.sh:
Code: [Select]
#!/bin/bash
echo helloworld
« Last Edit: June 04, 2010, 05:01:12 PM by personage »

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Permanent disable DHCP + run script at startup
« Reply #4 on: June 04, 2010, 05:37:56 PM »
use ls -l to verify that it is executable.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Permanent disable DHCP + run script at startup
« Reply #5 on: June 04, 2010, 06:06:17 PM »
bash is not included in the base.

(fyi: if it was just missing the executable bit, it would be a different error)

Offline personage

  • Newbie
  • *
  • Posts: 6
Re: Permanent disable DHCP + run script at startup
« Reply #6 on: June 04, 2010, 06:14:04 PM »
Quote from: ^thehatsrule^
bash is not included in the base.
Arh, thank you very much, I should have thought about that:)
I'm trying it out.

Offline personage

  • Newbie
  • *
  • Posts: 6
Re: Permanent disable DHCP + run script at startup
« Reply #7 on: June 05, 2010, 04:50:15 AM »
So I'm trying to install bash after ^thehatsrule^ advice, butI seem to be a bit confused.

To install bash during boot do I have to:
a) Put bash.tcz and onboot.lst in /tce/?
b) Put bash.tcz and onboot.lst in /opt/tce?

Because my script still refuses to run when I'm using any of them, even manually after boot.
The error given is still the same (No such file or directory).

Content of my onboot.lst:
Code: [Select]
bash.tcz
I'm emulating the remastered iso in qemu, if that should make any difference.

Offline personage

  • Newbie
  • *
  • Posts: 6
Re: Permanent disable DHCP + run script at startup
« Reply #8 on: June 05, 2010, 07:52:12 AM »
Alright, I got it working now.

I simply added the commands to tc-config, and it works :)
It might not look nice, but it gets the job done.

Offline ^thehatsrule^

  • Retired Admins
  • Hero Member
  • *****
  • Posts: 1726
Re: Permanent disable DHCP + run script at startup
« Reply #9 on: June 05, 2010, 03:17:23 PM »
I guess you already found out that there was no need for bash at all (I overlooked your script).

Offline personage

  • Newbie
  • *
  • Posts: 6
Re: Permanent disable DHCP + run script at startup
« Reply #10 on: June 06, 2010, 02:45:42 PM »
Yep, that was also my conclusion ;D