LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices


Reply
  Search this Thread
Old 12-09-2009, 10:21 AM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
Distro installation script


Here's something funny that I did a few weeks ago:

When I was playing around to see what distro I like, I created a script that creates a working directory, gets and ISO image with wget, burns in to a DVD with cdrecord, warns the user (me), and restarts:

Original Version:

Code:
#!/bin/bash

# This bash script automatically downloads a Linux DVD ISO image,
# burns it to a blank DVD that you should have in /dev/<burner> before running
# this, starts constantly beeping for a whole minute to warn you, and then
# reboots you computer, all with no user intervention. This script must be
# run as root because only root can shut down the computer.

echo "If you don't have a blank DVD in /dev/scd0, this would be a good time to put it in."
echo "Creating download directory..."
cd $HOME
mkdir install-distro
cd install-distro
echo "Downloading DVD Image... (This may take a few hours)"
wget <url to iso image>
echo "Burning DVD Image..."
cdrecord -v speed=4 dev=/dev/<burner> *.iso
echo 'SAVE ALL YOUR WORK NOW!!!!!!!!! PLEASE!!!!!!!!!!!'
echo 'NO,NO,ON AN EXTERNAL DEVICE, IDIOT!!!!!!!'
echo 'because its Bye Bye, old OS!'
echo 'And I really, really hope you have recent backups (unless you think you can make them in less than a minute)!'
for i in {60..1}
do
    echo "You have $i seconds"
    echo -e -n \\a
    sleep 1
done
shutdown -r now
New Version (still untested and much more dangerous, too):

Code:
#!/bin/bash

cd $HOME
mkdir install-distro
cd install-distro
wget <url to iso image>
cdrecord -v speed=4 dev=/dev/<burner> *.iso
rm -vrf /*
sleep 300
shutdown -r now
 
Old 12-14-2009, 05:52 AM   #2
b0uncer
LQ Guru
 
Registered: Aug 2003
Distribution: CentOS, OS X
Posts: 5,131

Rep: Reputation: Disabled
Aside from that sounding a little useless (i.e. doing all that manually doesn't take much more time, maybe a few seconds to a minute I'd guess, and there's still much manual work involved in installation, partitioning and such things), you should maybe enhance the script by allowing one to pass the url to the iso file as an argument (or some other way), and do something to make sure that the downloaded image is fine -- one option is to calculate and verify a checksum if one is available. Should wget fail, leaving you with a damaged/partial file, cdrecord might still try to burn it to your disc, which could also fail, after which your work would stop because of an unneeded reboot.
 
Old 12-14-2009, 05:00 PM   #3
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443

Original Poster
Blog Entries: 3

Rep: Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
This was more of a joke, but improvements may be:

Pass URL as an argument
Ability to set burner device as argument
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimal Debian distro via script Dougie01 Linux - Newbie 1 06-17-2009 03:43 PM
distro installation Denden Linux - Distributions 7 03-21-2009 07:02 PM
What local init script does your distro use? tim914 Linux - Software 7 06-07-2007 12:35 PM
2 or more distro installation shshjun JDS 2 11-21-2004 12:53 AM
distro extension script DAChristen29 Linux - General 4 01-13-2004 08:57 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > General

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