#!/bin/bash
# Author: Steven Shiau <steven _at_ nchc org tw>
# License: GPL
# Program to create Clonezilla live.

# load config file
. /ocs-live.conf
# load functions
. /ocs-live-hook-functions 

# preset lo network setting
cat <<-NET_END > /etc/network/interfaces
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

NET_END

# set root passwd, I do not like root without passwd.
set_root_passwd

# We have to create account casper, otherwise there is a problem when we put command in casper's ~/.bash_profile. See ocs-live-hook-functions for more details.
create_account_casper

#
append_start_clonezilla_in_casper_bash_profile

# put the clonezilla live script in rcS.d
move_ocs_live_startup_to_rcS.d

# for better security
turn_off_ssh_service

# some required modules at startup
append_mod_in_etc_modules

# we need real /sbin/start-stop-daemon
remove_cdebootstrap-helper-diverts

# run localepurge
set_localepurge
localepurge

# Fix the bug about login prompt too early (Ref: https://bugs.launchpad.net/ubuntu/+source/upstart/+bug/65230)
fix_ubuntu_upstart_tty1_6_distorted_if_necessary

#
append_framebuffer_modules_for_ubuntu_if_necessary

# ///Note/// This should be the last one after any apt-get.
# clean unnecessary backup file to save space
clean_unnecessary_backup_file_in_boot

### THE END ###
# DO NOT PUT SCRIPT AFTHER THIS!!!
# kill this program before creating squashfs filesystem.
clean_ocs_hook_files_in_chroot
