Browse Source

Add stuff to /etc/hosts after install or LiveCD boot

Also regenerate SSH keys at LiveCD boot, but not at install, so that
they don't change after booting a live system.
tags/nilmbuntu-5
Jim Paris 4 years ago
parent
commit
eaa16f87b1
3 changed files with 42 additions and 31 deletions
  1. +6
    -0
      customize-inner.sh
  2. +3
    -31
      customize.sh
  3. +33
    -0
      preseed.cfg

+ 6
- 0
customize-inner.sh View File

@@ -26,6 +26,12 @@ export BUILD_SYSTEM="Ubuntu"
export FLAVOUR="NILMbuntu"
EOF

# Set up NILM-specific stuff to get added to /etc/hosts after installation
cat >/etc/hosts.nilm <<"EOF"
127.0.2.1 nilm.primary
127.0.2.2 nilm.secondary
EOF

# Upgrade packages and remove old kernels
apt-get update
apt-get -y dist-upgrade


+ 3
- 31
customize.sh View File

@@ -13,37 +13,9 @@ sed -i -s -e \
# out the distro name in dialogs, and I think casper might use it too
echo "NILMbuntu $VERSION" > ${ISO}/.disk/info

# Set up preseed file
cp ${ISO}/preseed/xubuntu.seed ${ISO}/preseed/nilmbuntu.seed
cat >> ${ISO}/preseed/nilmbuntu.seed <<"EOF"
# Commands to run on successful install:
# - Regenerate SSH host keys
# - Remove "quiet splash" from grub command line
# Ubiquity doesn't actually use preseed/late_command, so we do it
# in ubiquity/success_command (which needs things mounted)
ubiquity ubiquity/success_command string \
echo "success_command running" >/target/var/log/installer/postinst.log; \
for i in /dev /dev/pts /dev/shm /sys /sys/kernel/security /proc /cdrom; do \
mount --bind $i /target/$i; done; \
sed -i -e 's/quiet splash//g' /target/etc/default/grub; \
chroot /target update-grub \
>>/target/var/log/installer/postinst.log 2>&1; \
rm -f /target/etc/ssh/ssh_host_*; \
chroot /target dpkg-reconfigure openssh-server \
>>/target/var/log/installer/postinst.log 2>&1; \
for i in /dev/pts /dev/shm /dev /sys/kernel/security /sys /proc /cdrom; do \
umount /target/$i; done; \
echo "success_command done" >>/target/var/log/installer/postinst.log

# Default user. Ubiquity should let them change this.
# (To skip the dialog completely, maybe set a password?)
d-i passwd/user-fullname string NILM User
d-i passwd/username string nilm
#d-i passwd/user-password password nilm
#d-i passwd/user-password-again password nilm
d-i user-setup/allow-password-weak boolean true
d-i passwd/auto-login boolean true
EOF
# Set up preseed file by appending preseed.cfg to the Xubuntu
# default one
cat ${ISO}/preseed/xubuntu.seed preseed.cfg > ${ISO}/preseed/nilmbuntu.seed

# Set up isolinux how we want by editing its config
TRY="Boot ^NILMbuntu ${VERSION}"


+ 33
- 0
preseed.cfg View File

@@ -0,0 +1,33 @@
# Commands to run at casper boot:
# - Regenerate SSH keys
# - Append /etc/hosts.nilm to /etc/hosts
d-i preseed/early_command string \
echo "early_command running" ; \
chroot /root sh -c "rm -f /etc/ssh/ssh_host_*" ; \
chroot /root sh -c "dpkg-reconfigure openssh-server" ; \
chroot /root sh -c "cat /etc/hosts.nilm >> /etc/hosts" ; \
echo "early_command done"

# Commands to run on successful install:
# (Ubiquity doesn't actually use preseed/late_command, so we do it
# in ubiquity/success_command (which needs things mounted))
# - Remove "quiet splash" from grub command line
# - Append /etc/hosts.nilm to /etc/hosts
ubiquity ubiquity/success_command string \
echo "success_command running" >/target/var/log/installer/postinst.log; \
mount --bind /dev /target/dev ; \
in-target sh -c "sed -i -e 's/quiet splash//g' /etc/default/grub" ; \
in-target sh -c "update-grub >>/var/log/installer/postinst.log 2>&1" ; \
in-target sh -c "cat /etc/hosts.nilm >> /etc/hosts " ; \
umount /target/dev ; \
echo "success_command done" >>/target/var/log/installer/postinst.log

# Default user. Ubiquity should let them change this.
# (To skip the dialog completely, maybe set a password?)
d-i passwd/user-fullname string NILM User
d-i passwd/username string nilm
#d-i passwd/user-password password nilm
#d-i passwd/user-password-again password nilm
d-i user-setup/allow-password-weak boolean true
d-i passwd/auto-login boolean true
EOF

Loading…
Cancel
Save