Skip to content

Instantly share code, notes, and snippets.

@naa0yama
Last active August 6, 2017 05:13
Show Gist options
  • Save naa0yama/6ee046eede9668227299475d0bdb89ce to your computer and use it in GitHub Desktop.
Save naa0yama/6ee046eede9668227299475d0bdb89ce to your computer and use it in GitHub Desktop.
Appliance Automatic Installation Ubuntu

ハンズオン & 検証用 Ubuntu Server 16.04.2 LTS 半自動構築スクリプト

この設定ファイルでは、preseed を使用して、初期設定をするスクリプトになってます。

Users 

  • ID: root, user01
  • PASS: p@ssw0rd

Packages

  • bash-completion
  • curl
  • wget
  • ubuntu-desktop
  • psmisc
  • sshpass
  • tree
  • unzip
  • vim
  • zip

Settings

  • PermitRootLogin: yes
  • SUDO NOPASSWD

構築コマンド

apt-get -y install syslinux mtools mbr genisoimage dvd+rw-tools
mkdir -p ~/ubuntu1604
cd ~/ubuntu1604
curl -O http://ftp.iij.ad.jp/pub/linux/ubuntu/releases/16.04.2/ubuntu-16.04.1-server-amd64.iso
mkdir -p {dvd,dvdr}
mount -t iso9660 ubuntu-16.04.2-server-amd64.iso ~/ubuntu1604/dvd
cd dvd
find . ! -type l | cpio -pdum ~/ubuntu1604/dvdr/
genisoimage -N -J -R -D -V "PRESEED" -o ubuntu-16.04.1-server-amd64-preseed.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table ~/ubuntu1604/dvdr
default install
label install
menu label ^Automatic installation Ubuntu
kernel /install/vmlinuz
append DEBCONF_DEBUG=5 auto=true locale=en_US.UTF-8 console-setup/charmap=UTF-8 console-setup/layoutcode=us console-setup/ask_detect=false pkgsel/language-pack-patterns=pkgsel/install-language-support=false vga=normal file=/cdrom/preseed/preseed.seed initrd=/install/initrd.gz quiet --
label hd
menu label ^Boot from first hard disk
localboot 0x80
#===========================================================================================
# MIT License
#
# Copyright (c) 2017 Naoki Aoyama (@FoxBoxsnet)
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#===========================================================================================
# BOOT SEQUENCE CONFIGURATIONS START
# The settings become effective only if the far END set shipped on DVD media, USB media.
# This section is ignored if the PXE boot.
#===========================================================================================
d-i debian-installer/language string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i localechooser/supported-locales en_US.UTF-8
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i console-setup/charmap select UTF-8
# Characteristics of the keyboard layout settings (Japan language keyboard)
d-i keyboard-configuration/layoutcode string jp
d-i keyboard-configuration/modelcode jp106
#===========================================================================================
# Network settings
#-------------------------------------------------------------------------------------------
# Static IP
#-------------------------------------------------------------------------------------------
# Important do not set the following two items are not treated as static IP
d-i netcfg/use_autoconfig boolean false
d-i netcfg/disable_autoconfig boolean true
#===========================================================================================
# Select a mirror to download the Installer package
#-------------------------------------------------------------------------------------------
d-i mirror/country string manual
d-i mirror/http/hostname string jp.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu/
d-i mirror/http/proxy string
#===========================================================================================
# Clock and time zone setup
#-------------------------------------------------------------------------------------------
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Tokyo
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.nict.jp
#===========================================================================================
# Partitioning
#-------------------------------------------------------------------------------------------
# d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose_recipe select atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#===========================================================================================
# Base system installation
#-------------------------------------------------------------------------------------------
d-i base-installer/kernel/image string linux-server
#===========================================================================================
#### Account setup
#-------------------------------------------------------------------------------------------
## Root account setup
#-------------------------------------------------------------------------------------------
d-i passwd/root-login boolean true
d-i passwd/make-user boolean true
d-i passwd/root-password p@ssw0rd p@ssw0rd
d-i passwd/root-password-again p@ssw0rd p@ssw0rd
#-------------------------------------------------------------------------------------------
## To create a normal user01 account.
#-------------------------------------------------------------------------------------------
d-i passwd/user-fullname string user01
d-i passwd/username string user01
d-i passwd/user-password p@ssw0rd p@ssw0rd
d-i passwd/user-password-again p@ssw0rd p@ssw0rd
d-i user-setup/allow-password-weak boolean true
d-i passwd/user-default-groups string sudo
d-i user-setup/encrypt-home boolean false
#===========================================================================================
# Package selection
#-------------------------------------------------------------------------------------------
#tasksel tasksel/first multiselect none
tasksel tasksel/first multiselect none
## openssh-server, vim, tmux
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
popularity-contest popularity-contest/participate boolean false
d-i pkgsel/updatedb boolean true
#===========================================================================================
# GRUB Installer
#-------------------------------------------------------------------------------------------
d-i grub-installer/grub2_instead_of_grub_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string /dev/sda
#===========================================================================================
# Restart the server after installation
#-------------------------------------------------------------------------------------------
d-i finish-install/reboot_in_progress note
#===========================================================================================
# This first command is run as early as possible, just after
# preseeding is read.
#-------------------------------------------------------------------------------------------
d-i preseed/late_command string apt-install bash-completion curl wget ubuntu-desktop psmisc sshpass tree unzip vim zip; \
in-target apt-get -y update; \
in-target apt-get -y upgrade; \
in-target apt-get -y clean; \
in-target sed -i -e "s/PermitRootLogin prohibit-password/PermitRootLogin yes/g" /etc/ssh/sshd_config; \
in-target sed -i -e "s/%sudo ALL=(ALL:ALL) ALL/%sudo ALL=(ALL:ALL) NOPASSWD:ALL/g" /etc/sudoers \
in-target curl -sSL https://releases.rancher.com/install-docker/1.12.sh | sh \
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment