1

I have a pre-configured server based on Debian with some services. I, now, need to deploy it in different networks.

Is there any solution to run a one time script after reboot which asks some questions about network configuration and to make this change?

1 Answer 1

1

You can put your script in an executable file, which, when run, as the last thing, makes itself non-executable. You may call it from /etc/rc.local, checking, before running it, whether the file is executable. If it is, fine, just run it, otherwise don't.

In your /etc/rc.local, include a statement like

 if [ -x /home/myname/bin/myscript.sh ]; then /home/myname/bin/myscript.sh; fi

Then put your commands in the file /home/myname/bin/myscript.sh, allowing it to begin as:

  #!/bin/sh

  START_DIR=$PWD
  SCRIPT_NAME=$0
  ......

and put, as the last line to be executed:

  chmod 644 $START_DIR/$SCRIPT_NAME

Make the file executable (chmod 755 myscript.sh).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .