From ebbd90ccfb43a8693e907b50d1c459e3ef77b2cd Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Fri, 11 May 2018 14:38:01 +1000 Subject: [PATCH 1/6] tweak inithooks.service & add inithooks-lxc.service (support lxc) - closes #1071 --- debian/inithooks-lxc.service | 13 +++++++++++++ debian/inithooks.service | 1 + 2 files changed, 14 insertions(+) create mode 100644 debian/inithooks-lxc.service diff --git a/debian/inithooks-lxc.service b/debian/inithooks-lxc.service new file mode 100644 index 0000000..e798d75 --- /dev/null +++ b/debian/inithooks-lxc.service @@ -0,0 +1,13 @@ +[Unit] +Description=inithooks-lxc: firstboot and everyboot initialization scripts (lxc) +After=console-getty.service +ConditionKernelCommandLine=!noinithooks +ConditionVirtualization=lxc + +[Service] +Type=oneshot +EnvironmentFile=/etc/default/inithooks +ExecStart=/bin/sh -c '${INITHOOKS_PATH}/run' + +[Install] +WantedBy=basic.target diff --git a/debian/inithooks.service b/debian/inithooks.service index 3dad04a..1b1931b 100644 --- a/debian/inithooks.service +++ b/debian/inithooks.service @@ -2,6 +2,7 @@ Description=inithooks: firstboot and everyboot initialization scripts After=getty@tty8.service ConditionKernelCommandLine=!noinithooks +ConditionVirtualization=!lxc [Service] Type=oneshot From 0399b35fae4f626a756c82d1722e94a273c49aee Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Fri, 11 May 2018 14:41:09 +1000 Subject: [PATCH 2/6] force non-interactive dpkg-reconfigure - closes #1085 --- firstboot.d/10regen-sshkeys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firstboot.d/10regen-sshkeys b/firstboot.d/10regen-sshkeys index 52dc611..74c64da 100755 --- a/firstboot.d/10regen-sshkeys +++ b/firstboot.d/10regen-sshkeys @@ -7,4 +7,4 @@ echo "* Regenerating SSH cryptographic keys" rm -f /etc/ssh/*_key{,.pub} -dpkg-reconfigure openssh-server +dpkg-reconfigure --frontend=noninteractive --no-reload openssh-server From bcdd2ef4f79be5ded31a3ce5939fe25290af1761 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Fri, 11 May 2018 17:46:19 +1000 Subject: [PATCH 3/6] updated initfence index page (webshell not avaialble) - closes #1087 --- turnkey-init-fence/htdocs/index.html | 31 ++++++++++++++++++---------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/turnkey-init-fence/htdocs/index.html b/turnkey-init-fence/htdocs/index.html index 292c4f1..5b15775 100644 --- a/turnkey-init-fence/htdocs/index.html +++ b/turnkey-init-fence/htdocs/index.html @@ -8,7 +8,7 @@

Please initialize this system...

Welcome to TurnKey! You need to initialize this system first before - you can use it. To do that you'll need to log into the root account. + you can use it. To do that you'll need to log into the root account via SSH. The turnkey-init initialization program will start automatically:

@@ -20,12 +20,21 @@

Please initialize this system...

Can I log in without SSH?

-

Yes. Point your browser at this machine's webshell :

- - +

No. Unfortunately not.

-

Expect a browser warning regarding unsafe HTTPS encryption. This is - unavoidable with the use of auto generated self-signed SSL certificates.

+

How do I log in via SSH?

+ +

If you are connecting from Linux or MacOS, please open your terminal app + and type the command:

+ +
ssh example
+ +

If you are connecting from Windows, you will need to install an SSH client, such as + PuTTY. + Then connect to: IP ADDRESS OR FQDN

+ +

Note: you will need to have set a root password, or configured SSH keys before + logging in

For more information, visit our website!

@@ -38,9 +47,9 @@

For more information, visit our website!

+ + + From 3d6b0aa5bc88412ad8d75c4c8205d9450dec15f1 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Fri, 11 May 2018 17:50:40 +1000 Subject: [PATCH 4/6] update init-fence enable/disable inithooks to use systemctl commands --- firstboot.d/30turnkey-init-fence | 4 ++-- firstboot.d/97turnkey-init-fence-disable | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/firstboot.d/30turnkey-init-fence b/firstboot.d/30turnkey-init-fence index 1e15fa8..076f083 100644 --- a/firstboot.d/30turnkey-init-fence +++ b/firstboot.d/30turnkey-init-fence @@ -10,6 +10,6 @@ USERNAME=root PROFILE_FIRSTLOGIN=$(eval printf ~$USERNAME)/.profile.d/turnkey-init-fence [ -f $PROFILE_FIRSTLOGIN ] && chmod +x $PROFILE_FIRSTLOGIN -update-rc.d turnkey-init-fence defaults -/etc/init.d/turnkey-init-fence start +systemctl enable turnkey-init-fence +systemctl start turnkey-init-fence echo 'turnkey-init-fence is up' diff --git a/firstboot.d/97turnkey-init-fence-disable b/firstboot.d/97turnkey-init-fence-disable index 1eacfaf..74bab95 100644 --- a/firstboot.d/97turnkey-init-fence-disable +++ b/firstboot.d/97turnkey-init-fence-disable @@ -2,10 +2,10 @@ [ -z "$_TURNKEY_INIT" ] && exit 0; # ONLY run from within turnkey-init -if [ -x /etc/init.d/turnkey-init-fence ]; then +if systemctl is-active --quiet turnkey-init-fence; then - update-rc.d turnkey-init-fence remove; - /etc/init.d/turnkey-init-fence stop; + systemctl disable turnkey-init-fence + systemctl stop turnkey-init-fence fi From 9aaecde6c46f560c88bc110958dc5b6e70a54280 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 14 May 2018 12:00:24 +1000 Subject: [PATCH 5/6] modify debian/rules to install inithooks-lxc.service properly - thanks @lamby --- debian/inithooks-lxc.service | 2 +- debian/inithooks.service | 2 +- debian/rules | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/debian/inithooks-lxc.service b/debian/inithooks-lxc.service index e798d75..93399cf 100644 --- a/debian/inithooks-lxc.service +++ b/debian/inithooks-lxc.service @@ -10,4 +10,4 @@ EnvironmentFile=/etc/default/inithooks ExecStart=/bin/sh -c '${INITHOOKS_PATH}/run' [Install] -WantedBy=basic.target +WantedBy=multi-user.target diff --git a/debian/inithooks.service b/debian/inithooks.service index 1b1931b..9f8df0d 100644 --- a/debian/inithooks.service +++ b/debian/inithooks.service @@ -18,4 +18,4 @@ ExecStart=/bin/sh -c '\ chvt $FGCONSOLE' [Install] -WantedBy=basic.target +WantedBy=multi-user.target diff --git a/debian/rules b/debian/rules index 042e416..83962f5 100755 --- a/debian/rules +++ b/debian/rules @@ -4,4 +4,8 @@ dh $@ --with=systemd,python2 override_dh_installinit: - dh_installinit -r --no-start -- start 15 2 . + dh_installinit --name=inithooks -r --no-start -- start 15 2 . + dh_installinit --name=inithooks-lxc -r --no-start -- start 15 2 . + +override_dh_systemd_enable: + dh_systemd_enable debian/*.service From d475afb5dff4a3c815f35321e03c9e62b64017bf Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Fri, 18 May 2018 17:56:30 +1000 Subject: [PATCH 6/6] revert to basic.target --- debian/inithooks-lxc.service | 2 +- debian/inithooks.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/inithooks-lxc.service b/debian/inithooks-lxc.service index 93399cf..e798d75 100644 --- a/debian/inithooks-lxc.service +++ b/debian/inithooks-lxc.service @@ -10,4 +10,4 @@ EnvironmentFile=/etc/default/inithooks ExecStart=/bin/sh -c '${INITHOOKS_PATH}/run' [Install] -WantedBy=multi-user.target +WantedBy=basic.target diff --git a/debian/inithooks.service b/debian/inithooks.service index 9f8df0d..1b1931b 100644 --- a/debian/inithooks.service +++ b/debian/inithooks.service @@ -18,4 +18,4 @@ ExecStart=/bin/sh -c '\ chvt $FGCONSOLE' [Install] -WantedBy=multi-user.target +WantedBy=basic.target