Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update

Signed-off-by: JiYou <jiyou09@gmail.com>
  • Loading branch information...
commit 34c20d16676d0823a912de8e4f143867ef3a9507 1 parent ccc0524
@JiYou authored
Showing with 325 additions and 1 deletion.
  1. +87 −1 README.md
  2. +170 −0 install.sh
  3. +45 −0 ks.cfg
  4. +17 −0 localrc
  5. +6 −0 update.sh
View
88 README.md
@@ -1,2 +1,88 @@
easyinstall
-===========
+===========
+
+Deploy openstack is an diffcult job for large useage and some researchers.
+For this purpose, we write this project for deploying openstak.
+
+Until now, this project just can install OS by PXE. Before using `install.sh`
+script, you have to check these settings.
+
+SIMPLE STEPS
+============
+
+All we used is ubuntu-12.04
+
+1 Install packages.
+
+apt-get install -y --force-yes dhcp3-server tftp-hpa \
+tftpd-hpa xinetd openssh-server apache2 \
+system-config-kickstart
+
+2 Change /etc/network/interfaces.
+
+ auto eth0
+ iface inet eth0 static
+ address 192.168.1.1
+ netmask 255.255.255.0
+ gateway 192.168.1.1
+ broadcast 192.168.1.255
+
+3 change iso path in localrc.
+ /dev/sr0 # If you use CD/DVD.
+ /tmp/ubuntu-12.04-amd64.iso # If you use iso file.
+
+4 run install.sh
+
+
+MORE SETTINGS
+=============
+
+1 PXE-Server
+
+ Ubuntu version: 12.04
+
+2 ISO
+
+ You may use both ISO/CDROM as installation source. We have checked that
+ ubuntu-12.04-amd64.iso works very well. If you want to use your iso file,
+ you have to change localrc as:
+
+ iso_path=/abs_isopath/ubuntu-12.04-amd64.iso
+
+3 KickStart file
+
+ We already prepare one kickstart file as a template. If you want to use your
+ own kickstart file. You may use `system-config-kickstart` GUI tool to generate
+ your own kickstart configuration file.
+
+ Note: You may config your password & username in localrc.
+
+ # point to you kickstart configure file.
+ ks_cfg=/abs_ks_file_path/ks.cfg or ks_cfg=ks.cfg
+
+ ROOT_PASSWORD=zaq12wsx
+ USER_NAME=openstak
+ USER_PASSWORD=zaq12wsx
+
+4 Install some deb packages.
+
+ You have to use `apt-get install` command line to install some packages. Such
+ as DHCP, xinetd, tftp-hpa, apache2.
+
+ Note: must use tftp-hpa to instead of tftp package.
+
+5 Check your Network.
+
+ In my network configuration, (after I use apt-get install some packages), I
+ write /etc/network/interfaces as below: (default)
+
+ auto eth0
+ iface inet eth0 static
+ address 192.168.1.1
+ netmask 255.255.255.0
+ gateway 192.168.1.1
+ broadcast 192.168.1.255
+
+ After you check your network, you may have to write your network information.
+ If you use 192.168.1.1 as your IP of PXE server. You may not change localrc
+ file. Otherwise you may have to change your localrc as you network info.
View
170 install.sh
@@ -0,0 +1,170 @@
+#!/bin/bash
+set -e
+set -o xtrace
+#---------------------------------------------------
+# Get the path of the script.
+#---------------------------------------------------
+
+TOP_DIR=$(cd $(dirname "$0") && pwd)
+
+#---------------------------------------------------
+# Set variable for kickstart/iso path.
+#---------------------------------------------------
+
+source $TOP_DIR/localrc
+ks_cfg=${ks_cfg:-$TOP_DIR/ks.cfg}
+iso_path=${iso_path:-/dev/sr0}
+
+#---------------------------------------------------
+# Change password of user and root in kickstart file.
+#---------------------------------------------------
+USER_NAME=${USER_NAME:-openstack}
+USER_PASSWORD=${USER_PASSWORD:-zaq12wsx}
+ROOT_PASSWORD=${ROOT_PASSWORD:-zaq12wsx}
+sed -i "s,%ROOT_PASSWORD%,$ROOT_PASSWORD,g" $ks_cfg
+sed -i "s,%USER_NAME%,$USER_NAME,g" $ks_cfg
+sed -i "s,%USER_PASSWORD%,$USER_PASSWORD,g" $ks_cfg
+
+
+#---------------------------------------------------
+# Install deb packages. Must use tftp-hpa.
+#---------------------------------------------------
+
+apt-get install -y --force-yes dhcp3-server tftp-hpa \
+tftpd-hpa xinetd openssh-server apache2
+
+#---------------------------------------------------
+# Configure the DHCP service.
+#---------------------------------------------------
+
+dhcp_conf=/etc/dhcp/dhcpd.conf
+
+cat <<"EOF"> $dhcp_conf
+ddns-update-style interim;
+ignore client-updates;
+allow booting;
+allow bootp;
+
+subnet %SUBNET% netmask %NETMASK% {
+option routers %GATEWAY%;
+option subnet-mask %NETMASK%;
+option domain-name-servers %GATEWAY%;
+option time-offset -18000;
+range dynamic-bootp %IP_BEGIN% %IP_END%;
+default-lease-time 21600;
+max-lease-time 43200;
+next-server %GATEWAY%;
+filename "/pxelinux.0";
+}
+EOF
+
+SUBNET=${SUBNET:-192.168.1.0}
+NETMASK=${NETMASK:-255.255.255.0}
+GATEWAY=${GATEWAY:-192.168.1.1}
+IP_BEGIN=${IP_BEGIN:-192.168.1.3}
+IP_END=${IP_END:-192.168.1.254}
+
+sed -i "s,%SUBNET%,$SUBNET,g" $dhcp_conf
+sed -i "s,%NETMASK%,$NETMASK,g" $dhcp_conf
+sed -i "s,%GATEWAY%,$GATEWAY,g" $dhcp_conf
+sed -i "s,%IP_BEGIN%,$IP_BEGIN,g" $dhcp_conf
+sed -i "s,%IP_END%,$IP_END,g" $dhcp_conf
+
+#---------------------------------------------------
+# Configuration for XINETD service.
+#---------------------------------------------------
+
+TFTP_PATH=${TFTP_PATH:-/opt/tftp}
+
+cat <<"EOF" > /etc/xinetd.conf
+defaults
+{
+ log_type = FILE /var/log/xinetd.log
+ log_on_success = HOST EXIT DURATION
+ log_on_failure = HOST ATTEMPT
+ instances = 30
+ cps = 50 10
+}
+includedir /etc/xinetd.d
+EOF
+
+cat <<"EOF" > /etc/xinetd.d/tftp
+service tftp
+{
+ socket_type = dgram
+ protocol = udp
+ wait = yes
+ user = root
+ server = /usr/sbin/in.tftpd
+ server_args = -u nobody -s %TFTP_PATH%
+ disable = no
+ per_source = 11
+ cps = 100 2
+ flags = IPv4
+}
+EOF
+sed -i "s,%TFTP_PATH%,$TFTP_PATH,g" /etc/xinetd.d/tftp
+
+cat <<"EOF" > /etc/default/tftpd-hpa
+# /etc/default/tftpd-hpa
+TFTP_USERNAME="tftp"
+TFTP_DIRECTORY="%TFTP_PATH%"
+TFTP_ADDRESS="0.0.0.0:69"
+TFTP_OPTIONS="--secure"
+EOF
+sed -i "s,%TFTP_PATH%,$TFTP_PATH,g" /etc/default/tftpd-hpa
+
+mkdir -p $TFTP_PATH
+mkdir -p /usr/share/empty
+
+
+#---------------------------------------------------
+# Copy files for network boot.
+#---------------------------------------------------
+
+# mount iso file on a temp dir.
+TEMP_DIR=`mktemp`; rm -rf $TEMP_DIR;
+mkdir -p $TEMP_DIR
+mount -o loop $iso_path $TEMP_DIR
+
+# copy iso files to http's dir.
+temp_str=`cat $ks_cfg | grep url`
+temp_str=${temp_str##*/}
+[[ -e /var/www/$temp_str ]] && rm -rf /var/www/$temp_str
+mkdir -p /var/www/$temp_str
+cp -rf $TEMP_DIR/* /var/www/$temp_str/
+umount $TEMP_DIR; rm -rf $TEMP_DIR
+
+# copy network boot loader from iso files.
+cp -rf /var/www/$temp_str/install/netboot/* $TFTP_PATH/
+cp -rf $ks_cfg /var/www/
+
+# touch two files, otherwise will get warnings.
+# Bootstrap warning .....Packages corrupted.
+touch /var/www/$temp_str/dists/precise/restricted/binary-amd64/Packages
+touch /var/www/$temp_str/dists/precise/restricted/binary-i386/Packages
+chmod a+r -R /var/www >/dev/null 2>&1
+
+#---------------------------------------------------
+# Change menu.......
+#---------------------------------------------------
+
+txt_cfg=$TFTP_PATH/ubuntu-installer/amd64/boot-screens/txt.cfg
+[[ -e $TFTP_PATH/txt.cfg ]] && cp -rf $TFTP_PATH/txt.cfg $txt_cfg
+
+menu_str=`cat $txt_cfg | grep append | sed -n "1p"`
+menu_str=${menu_str##*append}
+
+echo "label auto install" >> $txt_cfg
+echo " menu label ^Auto install" >> $txt_cfg
+echo " kernel ubuntu-installer/amd64/linux" >> $txt_cfg
+echo " append ks=http://$GATEWAY/`basename $ks_cfg` $menu_str" >> $txt_cfg
+
+
+#---------------------------------------------------
+# Restart service.......
+#---------------------------------------------------
+service xinetd restart
+service tftpd-hpa restart
+ufw disable
+set +o xtrace
View
45 ks.cfg
@@ -0,0 +1,45 @@
+#Generated by Kickstart Configurator
+#platform=x86
+
+#System language
+lang en_US
+#Language modules to install
+langsupport en_US
+#System keyboard
+keyboard us
+#System mouse
+mouse
+#System timezone
+timezone --utc Asia/Shanghai
+#Root password
+rootpw zaq12wsx
+#Initial user
+user openstack --fullname "openstack" --password zaq12wsx
+#Reboot after installation
+reboot
+#Use text mode install
+text
+#Install OS instead of upgrade
+install
+#Use Web installation
+url --url http://192.168.1.1/ubuntu
+#System bootloader configuration
+bootloader --location=mbr
+#Clear the Master Boot Record
+zerombr yes
+#Partition clearing information
+clearpart --all --initlabel
+#Disk partitioning information
+part /boot --fstype ext4 --size 400
+part swap --size 2000
+part / --fstype ext4 --size 1 --grow --maxsize 5000000
+#System authorization infomation
+auth --useshadow --enablemd5
+#Network information
+network --bootproto=dhcp --device=eth0
+#Firewall configuration
+firewall --disabled --trust=eth0 --http --ftp --ssh
+#Do not configure the X Window System
+skipx
+%post --interpreter=/bin/bash
+echo "abc" >> /tmp/run.sh
View
17 localrc
@@ -0,0 +1,17 @@
+iso_path=/dev/sr0
+ks_cfg=ks.cfg
+
+# Kickstart configureation
+ROOT_PASSWORD=zaq12wsx
+USER_NAME=openstack
+USER_PASSWORD=zaq12wsx
+
+# DHCP configuration
+SUBNET=192.168.1.0
+NETMASK=255.255.255.0
+GATEWAY=192.168.1.1
+IP_BEGIN=192.168.1.3
+IP_END=192.168.1.254
+
+# TFTP base path
+TFTP_PATH=/opt/tftp
View
6 update.sh
@@ -0,0 +1,6 @@
+#!/bin/bash
+tsocks git config --global user.name "JiYou"
+tsocks git config --global user.email "jiyou09@gmail.com"
+tsocks git add .
+tsocks git commit -asm "Update"
+tsocks git push
Please sign in to comment.
Something went wrong with that request. Please try again.