ubuntu 18.04 預設移掉了 /etc/rc.local 的功能
變成要用 systemd 的方式來運作,可是有點難用…
紀錄一下步驟,再來研究怎麼整合到 preseed 裡面
1. 建立 rc-local.service sudo vi /etc/systemd/system/rc-local.service 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [Unit] Description =/etc/rc.local CompatibilityConditionPathExists =/etc/rc.local[Service] Type =forkingExecStart =/etc/rc.local startTimeoutSec =0 StandardOutput =ttyRemainAfterExit =yes SysVStartPriority =99 [Install] WantedBy =multi-user.target
2. 建立 rc.local.bak 這個檔案的作用是,我只需要client在PXE 裝完系統後的第一次開機會發通知信件
所以如果一直保留著 /etc/rc.local 的變動,就變成每次開機都會送出信件
因此,需要先保留原本的 rc.local
在送出通知信件之後,就用原來的 rc.local 蓋掉修改過的 rc.local
sudo vi /etc/rc.local.bak 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 exit 0
3. 建立 rc.local sudo vi /etc/rc.local 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 hostname|mail -s pxe_install_complete changch@abc.com cp /etc/ rc.local.bak /etc/ rc.local exit 0
4. 修改 rc.local permission 1 sudo chmod +x /etc/rc.local
5. 啟用 rc-local service 1 sudo systemctl enable rc-local
ubuntu 18.04 preseeds files
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 d-i keyboard-configuration/xkb-keymap select us d-i console-setup/ask_detect boolean false d-i console-setup/layoutcode string us d-i keyboard-configuration/ask_detect boolean false d-i keyboard-configuration/layoutcode string us d-i localechooser/preferred-locale string en_US.UTF-8 d-i localechooser/supported-locales en_US.UTF-8 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/continentlist string Asia d-i netcfg/choose_interface select auto d-i mirror/country string manual d-i mirror/http/proxy string {{ proxy_env }} d-i mirror/http/hostname string {{ pxe_preseed_mirror }} d-i mirror/http/directory string /ubuntu d-i mirror/http/mirror select {{ pxe_preseed_mirror }} d-i netcfg/get_hostname string ubuntu d-i netcfg/get_domain string abc.com d-i passwd/root-login boolean false d-i passwd/user-fullname string Adminstrator d-i passwd/username string administrator d-i passwd/user-password-crypted password $6 $random_salt$VaSwPia0/6 XHIicZLTaDceuRo/f9A6V4WazuZF/lhgQOhRJcKPO5yZ/ZxtBWrAhlDZOQ7GI3s4bPr9485Shry. d-i user-setup/allow-password-weak boolean true d-i user-setup/encrypt-home boolean false d-i passwd/user-default-groups string audio cdrom video sudo adm d-i clock-setup/utc boolean true d-i time /zone string {{ pxe_preseed_timezone }} d-i clock-setup/ntp boolean true d-i tzconfig/choose_country_zone/Asia select Taipei d-i tzconfig/choose_country_zone_single boolean true d-i netcfg/wireless_wep string ubuntu d-i partman-auto/method string regular d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-auto/choose_recipe select default-disk-layout d-i partman-auto/expert_recipe string \ default-disk-layout :: \ 10240 20480 -1 ext4 \ $primary{ } $bootable{ } \ method{ format } format{ } \ use_filesystem{ } filesystem{ ext4 } \ label{ root } \ mountpoint{ / } \ . \ 1024 2048 200 % linux-swap \ method{ swap } format{ } \ . \ d-i partman/default_filesystem string ext4 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 d-i partman/mount_style select uuid d-i base-installer/kernel/image string linux-generic d-i apt-setup/restricted boolean true d-i apt-setup/universe boolean true d-i apt-setup/backports boolean true d-i apt-setup/services-select multiselect security d-i apt-setup/security_host string security.ubuntu.com d-i apt-setup/security_path string /ubuntu tasksel tasksel/first multiselect standard, openssh-server, ubuntu-desktop d-i pkgsel/include string ssh net-tools python2.7 axel curl vim unzip zip apt-file lynx elinks sysstat ntp htop screen apt-transport-https wget curl git rsync postfix mailutils d-i pkgsel/upgrade select safe-upgrade d-i pkgsel/update-policy select unattended-upgrades popularity-contest popularity-contest/participate boolean false d-i pkgsel/updatedb boolean true postfix postfix/main_mailer_type select Internet Site postfix postfix/mailname string pxe.abc.com postfix postfix/protocols select ipv4 popularity-contest popularity-contest/participate boolean false d-i grub-installer/only_debian boolean true d-i grub-installer/with_other_os boolean true d-i finish-install/keep-consoles boolean true d-i finish-install/reboot_in_progress note d-i cdrom-detect/eject boolean true d-i preseed/late_command string \ in -target wget in -target wget in -target wget in -target chmod +x /etc/rc.local .pxe ;\in -target chmod +x /etc/rc.local .bak ;\in -target cp /etc/rc.local .pxe /etc/rc.local ;\in -target systemctl enable rc-local ;\in -target ln -s /usr/bin/python3.6 /usr/bin/python