@@ -43,6 +43,9 Set default system locale. This setting can also be changed inside the running O | |||||
43 | ##### `TIMEZONE`="Europe/Berlin" |
|
43 | ##### `TIMEZONE`="Europe/Berlin" | |
44 | Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command. |
|
44 | Set default system timezone. All available timezones can be found in the `/usr/share/zoneinfo/` directory. This setting can also be changed inside the running OS using the `dpkg-reconfigure tzdata` command. | |
45 |
|
45 | |||
|
46 | ##### `EXPANDROOT`=true | |||
|
47 | Expand the root partition and filesystem automatically on first boot. | |||
|
48 | ||||
46 | #### Keyboard settings: |
|
49 | #### Keyboard settings: | |
47 | These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command. |
|
50 | These options are used to configure keyboard layout in `/etc/default/keyboard` for console and Xorg. These settings can also be changed inside the running OS using the `dpkg-reconfigure keyboard-configuration` command. | |
48 | ##### `XKBMODEL`="" |
|
51 | ##### `XKBMODEL`="" |
@@ -55,6 +55,7 XKBMODEL=${XKBMODEL:=""} | |||||
55 | XKBLAYOUT=${XKBLAYOUT:=""} |
|
55 | XKBLAYOUT=${XKBLAYOUT:=""} | |
56 | XKBVARIANT=${XKBVARIANT:=""} |
|
56 | XKBVARIANT=${XKBVARIANT:=""} | |
57 | XKBOPTIONS=${XKBOPTIONS:=""} |
|
57 | XKBOPTIONS=${XKBOPTIONS:=""} | |
|
58 | EXPANDROOT=${EXPANDROOT:=true} | |||
58 |
|
59 | |||
59 | # Network settings |
|
60 | # Network settings | |
60 | ENABLE_DHCP=${ENABLE_DHCP:=true} |
|
61 | ENABLE_DHCP=${ENABLE_DHCP:=true} | |
@@ -158,6 +159,11 else | |||||
158 | APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" |
|
159 | APT_INCLUDES="${APT_INCLUDES},locales,keyboard-configuration,console-setup" | |
159 | fi |
|
160 | fi | |
160 |
|
161 | |||
|
162 | # Add parted package, required to get partprobe utility | |||
|
163 | if [ "$EXPANDROOT" = true ] ; then | |||
|
164 | APT_INCLUDES="${APT_INCLUDES},parted" | |||
|
165 | fi | |||
|
166 | ||||
161 | # Add dbus package, recommended if using systemd |
|
167 | # Add dbus package, recommended if using systemd | |
162 | if [ "$ENABLE_DBUS" = true ] ; then |
|
168 | if [ "$ENABLE_DBUS" = true ] ; then | |
163 | APT_INCLUDES="${APT_INCLUDES},dbus" |
|
169 | APT_INCLUDES="${APT_INCLUDES},dbus" | |
@@ -602,14 +608,73 ssh-keygen -q -t ed25519 -N "" -f /etc/ssh/ssh_host_ed25519_key | |||||
602 | sync |
|
608 | sync | |
603 |
|
609 | |||
604 | systemctl restart sshd |
|
610 | systemctl restart sshd | |
605 |
sed -i ' |
|
611 | sed -i '/.*rc.firstboot/d' /etc/rc.local | |
606 | rm -f /etc/rc.firstboot |
|
612 | rm -f /etc/rc.firstboot | |
607 | EOM |
|
613 | EOM | |
608 | chmod +x $R/etc/rc.firstboot |
|
614 | chmod +x $R/etc/rc.firstboot | |
609 |
sed -i ' |
|
615 | sed -i '/exit 0/d' $R/etc/rc.local | |
|
616 | echo /etc/rc.firstboot >> $R/etc/rc.local | |||
610 | rm -f $R/etc/ssh/ssh_host_* |
|
617 | rm -f $R/etc/ssh/ssh_host_* | |
611 | fi |
|
618 | fi | |
612 |
|
619 | |||
|
620 | if [ "$EXPANDROOT" = true ] ; then | |||
|
621 | cat <<EOF > $R/etc/rc.expandroot | |||
|
622 | #!/bin/sh | |||
|
623 | ||||
|
624 | ROOT_PART=\$(mount | sed -n 's|^/dev/\(.*\) on / .*|\1|p') | |||
|
625 | PART_NUM=\$(echo \${ROOT_PART} | grep -o '[1-9][0-9]*$') | |||
|
626 | case "\${ROOT_PART}" in | |||
|
627 | mmcblk0*) ROOT_DEV=mmcblk0 ;; | |||
|
628 | sda*) ROOT_DEV=sda ;; | |||
|
629 | esac | |||
|
630 | if [ "\$PART_NUM" = "\$ROOT_PART" ]; then | |||
|
631 | logger -t "rc.expandroot" "\$ROOT_PART is not an SD card. Don't know how to expand" | |||
|
632 | return 0 | |||
|
633 | fi | |||
|
634 | # NOTE: the NOOBS partition layout confuses parted. For now, let's only | |||
|
635 | # agree to work with a sufficiently simple partition layout | |||
|
636 | if [ "\$PART_NUM" -gt 2 ]; then | |||
|
637 | logger -t "rc.expandroot" "Your partition layout is not currently supported by this tool." | |||
|
638 | return 0 | |||
|
639 | fi | |||
|
640 | LAST_PART_NUM=\$(parted /dev/\${ROOT_DEV} -ms unit s p | tail -n 1 | cut -f 1 -d:) | |||
|
641 | if [ \$LAST_PART_NUM -ne \$PART_NUM ]; then | |||
|
642 | logger -t "rc.expandroot" "\$ROOT_PART is not the last partition. Don't know how to expand" | |||
|
643 | return 0 | |||
|
644 | fi | |||
|
645 | # Get the starting offset of the root partition | |||
|
646 | PART_START=\$(parted /dev/\${ROOT_DEV} -ms unit s p | grep "^\${PART_NUM}" | cut -f 2 -d: | sed 's/[^0-9]//g') | |||
|
647 | [ "\$PART_START" ] || return 1 | |||
|
648 | # Get the possible last sector for the root partition | |||
|
649 | PART_LAST=\$(fdisk -l /dev/\${ROOT_DEV} | grep '^Disk.*sectors' | awk '{ print \$7 - 1 }') | |||
|
650 | [ "\$PART_LAST" ] || return 1 | |||
|
651 | # Return value will likely be error for fdisk as it fails to reload the | |||
|
652 | # partition table because the root fs is mounted | |||
|
653 | ### Since rc.local is run with "sh -e", let's add "|| true" to prevent premature exit | |||
|
654 | fdisk /dev/\${ROOT_DEV} <<EOF2 || true | |||
|
655 | p | |||
|
656 | d | |||
|
657 | \$PART_NUM | |||
|
658 | n | |||
|
659 | p | |||
|
660 | \$PART_NUM | |||
|
661 | \$PART_START | |||
|
662 | \$PART_LAST | |||
|
663 | p | |||
|
664 | w | |||
|
665 | EOF2 | |||
|
666 | # Reload the partition table, resize root filesystem then remove resizing code from this file | |||
|
667 | partprobe && | |||
|
668 | resize2fs /dev/\${ROOT_PART} && | |||
|
669 | logger -t "rc.expandroot" "Root partition successfuly resized." && | |||
|
670 | sed -i '/.*rc.expandroot/d' /etc/rc.local | |||
|
671 | rm -f /etc/rc.expandroot | |||
|
672 | EOF | |||
|
673 | chmod +x $R/etc/rc.expandroot | |||
|
674 | sed -i '/exit 0/d' $R/etc/rc.local | |||
|
675 | echo /etc/rc.expandroot >> $R/etc/rc.local | |||
|
676 | fi | |||
|
677 | ||||
613 | # Disable rsyslog |
|
678 | # Disable rsyslog | |
614 | if [ "$ENABLE_RSYSLOG" = false ]; then |
|
679 | if [ "$ENABLE_RSYSLOG" = false ]; then | |
615 | sed -i 's|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g' $R/etc/systemd/journald.conf |
|
680 | sed -i 's|[#]*ForwardToSyslog=yes|ForwardToSyslog=no|g' $R/etc/systemd/journald.conf |
General Comments 0
Vous devez vous connecter pour laisser un commentaire.
Se connecter maintenant