First Time After Install, Run Configuration Script

Hello,

My job is having me get back into Linux. It has been awhile since I messed with it. My company releases Software that runs on Linux. As such, when we release a new version of the software, we have it packaged with the entire Linux OS. As such, when it is sent to our clients, they install, and then have to reconfigure, the Host Name, IP Address, Netmask, and Gateway. Our test environment consists of over ten different Linux boxes and configurations. To make life easier for me, I have written a shell script allowing me a menu to change all of these and to also enable or disable the gateway and how to set/change the localadm password.

I want the script available to users to be able to run it anytime they need to. It works great. I would like to add one more thing to this. I want to be able to run the script automatically on the very first boot after the installation. The script is set up where you have to log in as root to run it. So here is the process I want to happen:

Install Disk
System starts up for very first time after install
Automatically logs in as root and runs script
Exits as root.

I realize Linux will only do what I tell it to. How do I tell it to do this?


Similar Content



Is LFS The Right Way To Build A Software Update Disk?

I'm very used to working on a linux machine, programing in Unix terminals all through college. That said, I have never needed to work with linux distributions or doing more than some apt-get software installation.

I need to make a CD. I need a machine to be able to boot from this CD. I would like there to be a unix terminal that runs a script automatically. This script must be able to mount an NFS drive, do simple networking (TCP/IP), and update the software on the machine running it through deleting/adding files.

I guess I need an .iso for a linux distro that has files and a script already on it that can be used to update a bunch of these specific machines?

Should I go through the LFS project in order to learn how to do this?

I'm pretty lost and need some help. Thanks!

Perl Script Not Running Via Cron

Hi All,

I have perl script which I am trying to run on 1st Monday via cron job.
So I scheduled it as follows:

0 0 1-7 * * root ["$(date '+%a')" = "Mon"] && /usr/bin/perl script.pl

But then it didn't run so checked cron log and it seemed like its missing the command. so added a \ in front of %a and then it picked up the whole command as per cron log.

But still it didnt ran the script. I then change the script to just && echo "test">/tmp/test

Still nothing. if I run it as /usr/bin/perl script.pl it runs though

Thanks in advance.

Shell Scripts

I am taking a Linux class and am doing horribly, I just do not understand Linux. Can anyone please tell me how to create a shell script containing the `echo`, `whoami`, `groups`, and `pwd` commands?

I can do these as individual commands but cannot figure out how to do this in a shell script and get the output to produce output similar to the following:

You a
root
You are a member of the following groups:
root bin daemon sys adm disk wheel
Your current working directory is:
/tmp

My hair is getting thinner and grayer because of this.. Please help!

Conky Script Not Found

guys help me plz............

i have install conky in my kali linux by using this command.

sudo apt-get install conky
sudo apt-get install conky-all

every thing is working fine but i wanted to change my default conky script so i used these command ..


leafpad ~/.conkyrc

to open my default conky script page but it open only blank page ...where is my default conky script page i can not find it?????


how can i find my deafult conky script page........... thanks

Best Way To Run Two Interdependent Scripts

Hi All,

I have two scripts, the aim of these two scripts is, to check whether a particular script is running or not, if it wont runs, then throw a mail.

How i Achieved this output is, I wrote first script.

I created an infinite while loop which performs below steps

1. It creates a touch file
2. Triggers the script which needs to be monitored if its working or not.
3. Removes the touch file.

If the second step fails, then the remove file command will not happen and the script will stuck there itself.

I created an another script which checks the creation time of the touch file and if it is more than ten minutes, it means the second step in the first script is hanged, which also means that particular script is not working.

So if the creation time is more than 2 minutes the second script will throw a mail.

Below are the two scripts.

Code:
#!/bin/ksh



userid="chansd"

filename="/apps/log/check.txt"

while true ;do
touch $filename
pass=`/apps/eDMZ/call_st.ksh $userid`
sleep 20
rm $filename
done

Below script checks the file creation time and throws email if it is older than 2 minutes
Code:
#!/bin/ksh


filename="/apps/log/check.txt"

if [ -f "${filename}" ]
then
if test "`find $filename -mmin +2`"
then
echo "script is not working ! Please act on it" | mail -s "Script  is not working" Example@mail.com
fi


else

        exit 1

fi


What im going to do is

1. I am going to run the first script in background so it runs forever.
2. I am going to run the second script in cron forevry 5 mins to check the file creation time.

3. So if the first script hangs . I will kill the process using process id and after the issue resolves with the inner script, I will run the main script again.

I am new to Linux, Please let me know if this approach will work as expected.

How To Run A "sudo" Script Without Password

Hi all,
I have a script where every line needs to be prefixed with sudo.
I was advised to run it as $ sudo /path/to/file.sh

This script needs to be scheduled in crontab to run. If I run it as above, will I be prompted for a password?
Also, one of the lines in the script is;
scp -r root@rem_server:/source/dir /local/dir
Does that mean I will have to provide two passwords: one for sudo and one for root?

Thanks,

I Need To Learn How To Install Software On Linux.

Hi. Sorry to be so stupid, but I just managed to load and install this Linux (which I really like a lot) on my previously windows <--(bad) system.
But now I need to upgrade some software (like Adobe flash), and I have no clue how to do this. I understand I should go to my original linux distrubutor, and select software thru them (my "Linux distro").
But actually, it's been awhile since I did the install, and I dont exactly remember where I even got this distribution. (I know, I'm dumb--sorry).
Is there a way I can look at my linux system files and see who my distribution is thru, and where is their website. Or would it be easier if I just went thru the whole download and install of linux again <--(not really looking forward to that).
Or even, am I wrong about going thru the distro to do installs/upgrades?
Anything you can tell me will be greatly appreciated.

Long Live Linux !! David K

How To Run Shell Script In Any Folder Except The Folder Which Contains The Shell Script

I am using a shell script named by test.sh, for example containing
Code:
address="$PWD"
echo "$address"

.
If I put it in folder temp1, and run test.sh, then it will give me the address of the current directory. But if I am now in folder temp2, and I want to run test.sh, I always need to copy test.sh to folder temp2, and then run it. Is there a way that I can run test.sh without copying it? I am not root user.

Blackscreen Installing Debian Jessie Upgrading From Debian Wheezy

OK, I've created my user, I read all the post like: "Sticky: Please READ this before posting!" and the recommended post.

This morning I tried to upgrade my Debian Wheezy to Debian Jessie. I took a while to read the release-notes, change the source.list typing "jessie" in order of "wheezy".

Then, I opened a script with:

# script -t 2>~/actualiza-a-jessie01.time -a ~/actualiza-a-jessie01.script

and, finally:

# apt-get dist-upgrade

The installation started and all was go on until the postgresql when the installation stops and there was nothing to do. A lot of time after I decide restar the computer but now it doesn't start.

Appears the Debian 8 start menu with:
GNU GRUP versión 2.02

And the menu options:
Debian GNU/Linux
Opciones avanzadas para Debian GNU/Linux
Memory test (memtest86+)
Memory test (memtest86+, serial console 115200)
Memory test (memtest86+, experimental multiboot)
Memory test (memtest86+, serial console 115200, experimental multiboot)

When I select GNU/Linux I only get:
Loanding, please wait...
fsck from util-linux 2.25.2
/dev/sda1: clean, 619892/30269440 files, 68856006/121052672 blocks

and then.... nothing.

What can I do to restore my computer?

Thanks in advance.

What Is A Good Linux Script For Changing An IP Address Statically In Ubuntu?

I have a shell script that currently changes the mac address of eth0 repeatedly. However, it does not change the public IP address, confirmed by wget -qO- ipinfo.io/ip .

PERIOD=10

while [ 1 ]
do
echo "Changing mac address..."
let lastup=`date +%s`
macchanger -A eth0
let diff=`date +%s`-$lastup
if [ "$diff" -lt "$PERIOD" ]
then
sleep $(($PERIOD-$diff))
echo "Changed mac address successfully."
echo
elif [ "$diff" -gt "$PERIOD" ]
then
echo "Command took longer than iteration period of $PERIOD seconds!"
fi
done

The script needs to change the IP Address statically.

Also, ultimately, what I am trying to accomplish, for security reasons, is to frequently and automatically change a computer's public IP address and mac address. This way, my office's computers, when using the Internet, has an additional form of protection.