From fa40a5cf3b0f3f46c54e61b29094c9ab486b3c9a Mon Sep 17 00:00:00 2001 From: ljf Date: Fri, 1 Sep 2017 03:10:31 +0200 Subject: [PATCH 01/10] [enh] Bootprompt is back --- bin/yunoprompt | 103 ++++++++++++++++++++++++++++++++++ data/other/yunoprompt.service | 14 +++++ debian/postinst | 3 + 3 files changed, 120 insertions(+) create mode 100644 bin/yunoprompt create mode 100644 data/other/yunoprompt.service diff --git a/bin/yunoprompt b/bin/yunoprompt new file mode 100644 index 000000000..212debdc9 --- /dev/null +++ b/bin/yunoprompt @@ -0,0 +1,103 @@ +#!/bin/bash + +ip=$(hostname --all-ip-address) + +i=0 +for key in /etc/ssh/ssh_host_*_key.pub ; do + output=$(ssh-keygen -l -f $key) + fingerprint[$i]=" - $(echo $output | cut -d' ' -f2) $(echo $output| cut -d' ' -f4)" + i=$(($i + 1)) +done + +cat > /etc/issue.net << EOF + '. ' '' -d. + /M+ h- .shh/ // /NMy- hMdosso + 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ + sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' + .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. + mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: + 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - + hy /yy: :- -. -Nh ' + . + +IP: ${ip} +SSH fingerprints: +${fingerprint[0]} +${fingerprint[1]} +${fingerprint[2]} +${fingerprint[3]} +${fingerprint[4]} +EOF +if [[ ! -f /etc/yunohost/installed ]] +then + if [[ ! -f /etc/yunohost/from_script ]] + then +sleep 5 +chvt 2 +cat << EOF + '. ' '' -d. + /M+ h- .shh/ // /NMy- hMdosso + 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ + sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' + .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. + mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: + 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - + hy /yy: :- -. -Nh ' + . + +IP: ${ip} +SSH fingerprints*: +${fingerprint[0]} +${fingerprint[1]} +${fingerprint[2]} +${fingerprint[3]} +${fingerprint[4]} +EOF + +echo -e "\e[m Post-installation \e[0m" +cat << EOF +Congratulations! YunoHost has been successfully installed. +Two more steps are required to activate the services of your server. +EOF +read -p "Proceed to post-installation? (y/n) " -n 1 + RESULT=1 + while [ $RESULT -gt 0 ]; do + if [[ $REPLY =~ ^[Nn]$ ]]; then + chvt 1 + exit 0 + fi + echo -e "\n" + /usr/bin/yunohost tools postinstall + let RESULT=$? + if [ $RESULT -gt 0 ]; then + echo -e "\n" + read -p "Retry? (y/n) " -n 1 + fi + done + fi +else # YunoHost is already post-installed + + domain=$(cat /etc/yunohost/current_host) +cat > /etc/issue << EOF + '. ' '' -d. + /M+ h- .shh/ // /NMy- hMdosso + 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ + sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' + .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. + mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: + 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - + hy /yy: :- -. -Nh ' + . + +IP: ${ip} +SSH fingerprints: +${fingerprint[0]} +${fingerprint[1]} +${fingerprint[2]} +${fingerprint[3]} +${fingerprint[4]} +EOF + + +fi + diff --git a/data/other/yunoprompt.service b/data/other/yunoprompt.service new file mode 100644 index 000000000..3c4df50f9 --- /dev/null +++ b/data/other/yunoprompt.service @@ -0,0 +1,14 @@ +[Unit] +Description=YunoHost boot prompt +After=getty@tty2.service + +[Service] +Type=simple +ExecStart=/usr/bin/yunoprompt +StandardInput=tty +TTYPath=/dev/tty2 +TTYReset=yes +TTYVHangup=yes + +[Install] +WantedBy=default.target diff --git a/debian/postinst b/debian/postinst index 7e91ffbb3..39063694b 100644 --- a/debian/postinst +++ b/debian/postinst @@ -24,6 +24,9 @@ do_configure() { "consider to start it by doing 'service yunohost-firewall start'." fi + # Yunoprompt + systemctl enable yunoprompt.service + # remove old PAM config and update it [[ ! -f /usr/share/pam-configs/my_mkhomedir ]] \ || rm /usr/share/pam-configs/my_mkhomedir From 6bbcf0ee95e03781f30b89a156f6f8ba9f7dbc2f Mon Sep 17 00:00:00 2001 From: ljf Date: Fri, 1 Sep 2017 03:16:52 +0200 Subject: [PATCH 02/10] [fix] Missing install path --- debian/install | 1 + 1 file changed, 1 insertion(+) diff --git a/debian/install b/debian/install index 70add7992..e9c79e963 100644 --- a/debian/install +++ b/debian/install @@ -3,6 +3,7 @@ sbin/* /usr/sbin/ data/bash-completion.d/yunohost /etc/bash_completion.d/ data/actionsmap/* /usr/share/moulinette/actionsmap/ data/hooks/* /usr/share/yunohost/hooks/ +data/other/yunoprompt.service /etc/systemd/system/ data/other/* /usr/share/yunohost/yunohost-config/moulinette/ data/templates/* /usr/share/yunohost/templates/ data/helpers /usr/share/yunohost/ From bd2ea3c12cf81eba6879de6d67c44bad3e66b96e Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 3 Oct 2017 18:46:29 +0200 Subject: [PATCH 03/10] [fix] Limit ascii logo to 79 characters --- bin/yunoprompt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index 212debdc9..9839564e3 100644 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -11,13 +11,13 @@ done cat > /etc/issue.net << EOF '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso + /M+ h- .shh/ // /NMy- hMdosso 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' + hy /yy: :- -. -Nh ' . IP: ${ip} From 44676438fe642b4843ecb56cae7a95d4e4c16b8b Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 3 Oct 2017 18:47:52 +0200 Subject: [PATCH 04/10] [fix] Limit ascii 2nd and 3rd logo to 79 char --- bin/yunoprompt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index 9839564e3..200e81933 100644 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -36,13 +36,13 @@ sleep 5 chvt 2 cat << EOF '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso + /M+ h- .shh/ // /NMy- hMdosso 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' + hy /yy: :- -. -Nh ' . IP: ${ip} @@ -80,13 +80,13 @@ else # YunoHost is already post-installed domain=$(cat /etc/yunohost/current_host) cat > /etc/issue << EOF '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso + /M+ h- .shh/ // /NMy- hMdosso 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' + hy /yy: :- -. -Nh ' . IP: ${ip} From f25ef833e935a2b8d70acde8863a6bd8b80eabfa Mon Sep 17 00:00:00 2001 From: "ljf (zamentur)" Date: Tue, 3 Oct 2017 18:50:46 +0200 Subject: [PATCH 05/10] [fix] Remove dead code --- bin/yunoprompt | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index 200e81933..83b28296f 100644 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -77,7 +77,6 @@ read -p "Proceed to post-installation? (y/n) " -n 1 fi else # YunoHost is already post-installed - domain=$(cat /etc/yunohost/current_host) cat > /etc/issue << EOF '. ' '' -d. /M+ h- .shh/ // /NMy- hMdosso From 75fc1c03c59e6ca8d36d6728f3e7d3376819aeb5 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 8 May 2018 20:32:34 +0200 Subject: [PATCH 06/10] Factorize the building of the logo at the top of the script --- bin/yunoprompt | 88 +++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 54 deletions(-) mode change 100644 => 100755 bin/yunoprompt diff --git a/bin/yunoprompt b/bin/yunoprompt old mode 100644 new mode 100755 index 83b28296f..bb71e96b9 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -1,7 +1,9 @@ #!/bin/bash +# Fetch ips ip=$(hostname --all-ip-address) +# Fetch SSH fingerprints i=0 for key in /etc/ssh/ssh_host_*_key.pub ; do output=$(ssh-keygen -l -f $key) @@ -9,7 +11,11 @@ for key in /etc/ssh/ssh_host_*_key.pub ; do i=$(($i + 1)) done -cat > /etc/issue.net << EOF +# +# Build the logo +# + +LOGO=$(cat << 'EOF' '. ' '' -d. /M+ h- .shh/ // /NMy- hMdosso 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ @@ -19,7 +25,18 @@ cat > /etc/issue.net << EOF 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - hy /yy: :- -. -Nh ' . - +EOF +) + +# ' Put a quote in comment to make vim happy about syntax highlighting :s + +# +# Build the actual message +# + +LOGO_AND_FINGERPRINTS=$(cat << EOF +"$LOGO" + IP: ${ip} SSH fingerprints: ${fingerprint[0]} @@ -28,38 +45,22 @@ ${fingerprint[2]} ${fingerprint[3]} ${fingerprint[4]} EOF +) + + +echo "$LOGO_AND_FINGERPRINTS" > /etc/issue.net + if [[ ! -f /etc/yunohost/installed ]] then - if [[ ! -f /etc/yunohost/from_script ]] - then -sleep 5 -chvt 2 -cat << EOF - '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso - 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ - sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' - .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. - mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: - 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' - . - -IP: ${ip} -SSH fingerprints*: -${fingerprint[0]} -${fingerprint[1]} -${fingerprint[2]} -${fingerprint[3]} -${fingerprint[4]} -EOF - -echo -e "\e[m Post-installation \e[0m" -cat << EOF -Congratulations! YunoHost has been successfully installed. -Two more steps are required to activate the services of your server. -EOF -read -p "Proceed to post-installation? (y/n) " -n 1 + if [[ ! -f /etc/yunohost/from_script ]] + then + sleep 5 + chvt 2 + echo "$LOGO_AND_FINGERPRINTS" + echo -e "\e[m Post-installation \e[0m" + echo "Congratulations! YunoHost has been successfully installed. + Two more steps are required to activate the services of your server." + read -p "Proceed to post-installation? (y/n) " -n 1 RESULT=1 while [ $RESULT -gt 0 ]; do if [[ $REPLY =~ ^[Nn]$ ]]; then @@ -76,27 +77,6 @@ read -p "Proceed to post-installation? (y/n) " -n 1 done fi else # YunoHost is already post-installed - -cat > /etc/issue << EOF - '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso - 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ - sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' - .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. - mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: - 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' - . - -IP: ${ip} -SSH fingerprints: -${fingerprint[0]} -${fingerprint[1]} -${fingerprint[2]} -${fingerprint[3]} -${fingerprint[4]} -EOF - - + echo "$LOGO_AND_FINGERPRINTS" > /etc/issue fi From a897ec94f8b6a2265f5c2827ecaacbc9bd4f2000 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Tue, 15 May 2018 19:40:04 +0200 Subject: [PATCH 07/10] Remove a line which I added for test / debug --- bin/yunoprompt | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index bb71e96b9..ab9068d26 100755 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -47,9 +47,6 @@ ${fingerprint[4]} EOF ) - -echo "$LOGO_AND_FINGERPRINTS" > /etc/issue.net - if [[ ! -f /etc/yunohost/installed ]] then if [[ ! -f /etc/yunohost/from_script ]] From 2a4713f785c205a8ad13ba8d136da63779024756 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Thu, 17 May 2018 22:23:18 +0200 Subject: [PATCH 08/10] Alternative logo + misc tweak / cleaning --- bin/yunoprompt | 64 ++++++++++++++++++++++++-------------------------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index ab9068d26..5a7992789 100755 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -16,15 +16,13 @@ done # LOGO=$(cat << 'EOF' - '. ' '' -d. - /M+ h- .shh/ // /NMy- hMdosso - 'MN' /' '. -' :+ N: .Nmyym yo .MN' omNds: :mN' .sydMMMNds+ - sMh:/dN: :M' m: oMh' .M: dy h' MM: 'Mo oMh:-sMh /ddNdyyNM' - .sMMy' /M' /M- sMMd/sM- -Ms +M+ MM: +M/ mM' -Md 'NM. hM. - mM .M- :NN yMMMMMM: .dMNNMd' -/oMMmhmMMh /msosNM/ ::oMM. +M: - 'MN sMNMM+ mN:.+mM+ -+o/ :hMMm+- 'oN- :oyo- 'yho. - - hy /yy: :- -. -Nh ' - . + .--------------. + | \\ / _ _ | + | | |_|| |(_) | + | | + | |_| _ __|_ | + | | |(_)_\\ | | + '______________' EOF ) @@ -35,15 +33,17 @@ EOF # LOGO_AND_FINGERPRINTS=$(cat << EOF -"$LOGO" -IP: ${ip} -SSH fingerprints: -${fingerprint[0]} -${fingerprint[1]} -${fingerprint[2]} -${fingerprint[3]} -${fingerprint[4]} +$LOGO + + IP: ${ip} + SSH fingerprints: + ${fingerprint[0]} + ${fingerprint[1]} + ${fingerprint[2]} + ${fingerprint[3]} + ${fingerprint[4]} + EOF ) @@ -55,25 +55,23 @@ then chvt 2 echo "$LOGO_AND_FINGERPRINTS" echo -e "\e[m Post-installation \e[0m" - echo "Congratulations! YunoHost has been successfully installed. - Two more steps are required to activate the services of your server." + echo "Congratulations! YunoHost has been successfully installed.\nTwo more steps are required to activate the services of your server." read -p "Proceed to post-installation? (y/n) " -n 1 - RESULT=1 - while [ $RESULT -gt 0 ]; do - if [[ $REPLY =~ ^[Nn]$ ]]; then + RESULT=1 + while [ $RESULT -gt 0 ]; do + if [[ $REPLY =~ ^[Nn]$ ]]; then chvt 1 - exit 0 - fi - echo -e "\n" - /usr/bin/yunohost tools postinstall - let RESULT=$? - if [ $RESULT -gt 0 ]; then - echo -e "\n" - read -p "Retry? (y/n) " -n 1 - fi - done + exit 0 + fi + echo -e "\n" + /usr/bin/yunohost tools postinstall + let RESULT=$? + if [ $RESULT -gt 0 ]; then + echo -e "\n" + read -p "Retry? (y/n) " -n 1 + fi + done fi else # YunoHost is already post-installed echo "$LOGO_AND_FINGERPRINTS" > /etc/issue fi - From c0be9676e37c9a6b13c48070b29897e1efefc1a7 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 May 2018 00:46:48 +0200 Subject: [PATCH 09/10] Rework condition (and remove the 'from_script' flag) --- bin/yunoprompt | 47 ++++++++++++++++++++++------------------------- 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index 5a7992789..b92f2d209 100755 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -47,31 +47,28 @@ $LOGO EOF ) -if [[ ! -f /etc/yunohost/installed ]] +if [[ -f /etc/yunohost/installed ]] then - if [[ ! -f /etc/yunohost/from_script ]] - then - sleep 5 - chvt 2 - echo "$LOGO_AND_FINGERPRINTS" - echo -e "\e[m Post-installation \e[0m" - echo "Congratulations! YunoHost has been successfully installed.\nTwo more steps are required to activate the services of your server." - read -p "Proceed to post-installation? (y/n) " -n 1 - RESULT=1 - while [ $RESULT -gt 0 ]; do - if [[ $REPLY =~ ^[Nn]$ ]]; then - chvt 1 - exit 0 - fi - echo -e "\n" - /usr/bin/yunohost tools postinstall - let RESULT=$? - if [ $RESULT -gt 0 ]; then - echo -e "\n" - read -p "Retry? (y/n) " -n 1 - fi - done - fi -else # YunoHost is already post-installed echo "$LOGO_AND_FINGERPRINTS" > /etc/issue +else + sleep 5 + chvt 2 + echo "$LOGO_AND_FINGERPRINTS" + echo -e "\e[m Post-installation \e[0m" + echo "Congratulations! YunoHost has been successfully installed.\nTwo more steps are required to activate the services of your server." + read -p "Proceed to post-installation? (y/n) " -n 1 + RESULT=1 + while [ $RESULT -gt 0 ]; do + if [[ $REPLY =~ ^[Nn]$ ]]; then + chvt 1 + exit 0 + fi + echo -e "\n" + /usr/bin/yunohost tools postinstall + let RESULT=$? + if [ $RESULT -gt 0 ]; then + echo -e "\n" + read -p "Retry? (y/n) " -n 1 + fi + done fi From eb76ca3fafd71f15f3096c928c614eccc0c4d483 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Mon, 21 May 2018 00:48:39 +0200 Subject: [PATCH 10/10] Change logo again ('Modular' font from patorjk.com) --- bin/yunoprompt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/yunoprompt b/bin/yunoprompt index b92f2d209..de05dd6fa 100755 --- a/bin/yunoprompt +++ b/bin/yunoprompt @@ -16,13 +16,13 @@ done # LOGO=$(cat << 'EOF' - .--------------. - | \\ / _ _ | - | | |_|| |(_) | - | | - | |_| _ __|_ | - | | |(_)_\\ | | - '______________' + __ __ __ __ __ _ _______ __ __ _______ _______ _______ + | | | || | | || | | || || | | || || || | + | |_| || | | || |_| || _ || |_| || _ || _____||_ _| + | || |_| || || | | || || | | || |_____ | | + |_ _|| || _ || |_| || _ || |_| ||_____ | | | + | | | || | | || || | | || | _____| | | | + |___| |_______||_| |__||_______||__| |__||_______||_______| |___| EOF )