<commit_before>#!/bin/bash

#location_url=http://ftp.riken.jp/Linux/centos/6.2/os/x86_64/
location_url=http://ftp.kddilabs.jp/Linux/packages/CentOS/6.2/os/x86_64/

if [ $# -ne 2 ]; then
  echo Usage $0 hostname ipaddress
  exit 1
fi

hostname=$1
ipaddress=$2

ksfile=/tmp/$hostname-ks.cfg.$$
ksfdimg=/tmp/$hostname-ks.img.$$

make_ksfile() {
  cat <<EOF > $ksfile
install
url --url=http://ftp.riken.jp/Linux/centos/6.2/os/x86_64/
lang en_US.UTF-8
keyboard us
#network --onboot yes --device eth0 --bootproto dhcp --noipv6
network --device eth0 --bootproto static --ip ${ipaddress} --netmask 255.255.255.0 --gateway 192.168.11.1 --nameserver 192.168.11.1 --hostname ${hostname}
#rootpw  --iscrypted $6$9LqCbasGLPao4fBO$IH8yZaPJWsoNLZtMGD5jnwJ.uRq7dbNOpXKkMldZGObS0.8X9dXr3FEC0qBpKj1LjOR6RgGCeRD3rDGe.wZtp0
rootpw  password
firewall --service=ssh
authconfig --enableshadow --passalgo=<PASSWORD>512
selinux --disabled
timezone --utc Asia/Tokyo
bootloader --location=mbr --driveorder=vda --append=" crashkernel=auto console=ttyS0,115200n8"

clearpart --all --drives=vda
part /boot --fstype=ext4 --size=500
part pv.0 --grow --size=1
volgroup VolGroup pv.0
logvol swap --name=lv_swap --vgname=VolGroup --grow --size=1008 --maxsize=2016
logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200

repo --name="CentOS"  --baseurl=${location_url} --cost=100
user --name=hnakamur --password=password --uid=500

%packages --nobase
@core
file
man
openssh-clients
%end

%post

mkdir /home/hnakamur/.ssh
chmod 700 /home/hnakamur/.ssh
cat <<KEY_EOF > /home/hnakamur/.ssh/authorized_keys
ssh-rsa <KEY>== hnakamur@sunsh<PASSWORD>103
KEY_EOF
chmod 600 /home/hnakamur/.ssh/authorized_keys
chown -R hnakamur:hnakamur /home/hnakamur/.ssh

sed -i.orig -e '
s/^PasswordAuthentication yes/PasswordAuthentication no/
/^UsePAM yes/d
/^#PermitRootLogin yes/a\
PermitRootLogin no
/^X11Forwarding yes/d
' /etc/ssh/sshd_config

cat >>/etc/sudoers <<SUDOERS_EOF 

hnakamur ALL=(ALL)      NOPASSWD: ALL<commit_msg>Require no tty for sudo<commit_after>#!/bin/bash

#location_url=http://ftp.riken.jp/Linux/centos/6.2/os/x86_64/
location_url=http://ftp.kddilabs.jp/Linux/packages/CentOS/6.2/os/x86_64/

if [ $# -ne 2 ]; then
  echo Usage $0 hostname ipaddress
  exit 1
fi

hostname=$1
ipaddress=$2

ksfile=/tmp/$hostname-ks.cfg.$$
ksfdimg=/tmp/$hostname-ks.img.$$

make_ksfile() {
  cat <<EOF > $ksfile
install
url --url=http://ftp.riken.jp/Linux/centos/6.2/os/x86_64/
lang en_US.UTF-8
keyboard us
#network --onboot yes --device eth0 --bootproto dhcp --noipv6
network --device eth0 --bootproto static --ip ${ipaddress} --netmask 255.255.255.0 --gateway 192.168.11.1 --nameserver 192.168.11.1 --hostname ${hostname}
#rootpw  --iscrypted $6$9LqCbasGLPao4fBO$IH8yZaPJWsoNLZtMGD5jnwJ.uRq7dbNOpXKkMldZGObS0.8X9dXr3FEC0qBpKj1LjOR6RgGCeRD3rDGe.wZtp0
rootpw  password
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone --utc Asia/Tokyo
bootloader --location=mbr --driveorder=vda --append=" crashkernel=auto console=ttyS0,115200n8"

clearpart --all --drives=vda
part /boot --fstype=ext4 --size=500
part pv.0 --grow --size=1
volgroup VolGroup pv.0
logvol swap --name=lv_swap --vgname=VolGroup --grow --size=1008 --maxsize=2016
logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200

repo --name="CentOS"  --baseurl=${location_url} --cost=100
user --name=hnakamur --password=password --uid=500

%packages --nobase
@core
file
man
openssh-clients
%end

%post

mkdir /home/hnakamur/.ssh
chmod 700 /home/hnakamur/.ssh
cat <<KEY_EOF > /home/hnakamur/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAokqmX07JuL5EhDr9EHR6jhNKV0Im5l8Wv/F343NJs1X4qoKtvcixTTyl+BLNtczOLUbyzqVpCOjWIs2hDwYyrounFVw/+TM2abp4pFUgB6qnDY7T+8kSKw3mSAIjDt4rZIkuizzRonGsTkjw8hBT5OokUSR68xVcwaphdcu8ZvHp8/Um5+6eay4D1S0pDOEvf6FEhADDr1c10IPGwsCOpLcxSHCkVFOkZzmgSTSt/7BlX90278oyDOjIKEqisSwi0HaHWvsJ1C3WUtDFVpR85+rH70mt5UH2DbPfZ9W2to+Pgh7nNg95CO6H0geH1tWejS0yQ4ZE0EOKYuFaiPdMVQ== <EMAIL>3
KEY_EOF
chmod 600 /home/hnakamur/.ssh/authorized_keys
chown -R hnakamur:hnakamur /home/hnakamur/.ssh

sed -i.orig -e '
s/^PasswordAuthentication yes/PasswordAuthentication no/
/^UsePAM yes/d
/^#PermitRootLogin yes/a\
PermitRootLogin no
/^X11Forwarding yes/d
' /etc/ssh/sshd_config

cat >>/etc/sudoers <<SUDOERS_EOF 

Defaults:hnakamur !requiretty
hnakamur ALL=(ALL)      NOPASSWD: ALL
{'fraction_non_alphanumeric': 0.14370034052213393, 'fraction_numerical': 0.07014755959137343, 'mean_word_length': 4.514392991239049, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2617312', 'n_tokens_mistral': 2158, 'n_tokens_neox': 1942, 'n_words': 323}