Explorar el Código

Display of connection information + formatting

Laurent HUBERT hace 6 años
padre
commit
7e1124204c
Se han modificado 3 ficheros con 40 adiciones y 3 borrados
  1. 1 3
      deploy
  2. 19 0
      first-boot-script
  3. 20 0
      scripts/90-display-ip

+ 1 - 3
deploy

@@ -19,9 +19,7 @@ cp scripts/* $FIRST_BOOT_SCRIPTS_DIR
 touch $FIRST_BOOT_BASE_DIR/.mustrun
 
 # Deploys
-#https://unix.stackexchange.com/questions/265014/how-to-start-a-script-on-tty-instead-of-asking-for-login-in-systemd
-#https://stackoverflow.com/questions/14152026/how-can-i-automatically-login-on-a-tty-and-execute-a-script
-#https://unix.stackexchange.com/questions/401759/automatically-login-on-debian-9-2-1-command-line
+# See https://unix.stackexchange.com/questions/265014/how-to-start-a-script-on-tty-instead-of-asking-for-login-in-systemd
 systemctl enable first-boot-init.service
 
 echo "You can now run rm -r on this directory"

+ 19 - 0
first-boot-script

@@ -11,6 +11,12 @@ then
   exit 0
 fi
 
+cat <<EOF
+###############################################
+#  FIRST BOOT INITIALIZATION SCRIPT           #
+###############################################
+EOF
+
 if [[ $EUID -ne 0 ]]; then
 	 echo "This script cannot work if not super-user. Please run as root" 1>&2
 	 exit 1
@@ -24,6 +30,14 @@ do
     status=$?
     if [ 0 -ne "$status" ] ; then
       echo "#ERROR# : script $f did not finish with success status !"
+cat <<EOF
+###############################################
+###############################################
+#  FIRST BOOT INITIALIZATION : ERROR          #
+#  Please reboot your system                  #
+###############################################
+###############################################
+EOF
       exit $status
     fi
   fi
@@ -31,5 +45,10 @@ done
 
 rm $FIRST_BOOT_BASE_DIR/.mustrun
 systemctl disable first-boot-init.service
+cat <<EOF
+###############################################
+#  FIRST BOOT INITIALIZATION : success        #
+###############################################
+EOF
 
 exit 0

+ 20 - 0
scripts/90-display-ip

@@ -0,0 +1,20 @@
+#!/bin/bash
+# Licence : GPL v3
+# Author: Laurent HUBERT
+#
+# Display connection information
+#
+IP_V4_VALUE=$(ip a | grep -v host | grep inet | grep -v inet6 | awk '{print substr($2, 1, index($2, "/")-1)}')
+IP_V6_VALUE=$(ip a | grep -v host | grep inet6 | awk '{print substr($2, 1, index($2, "/")-1)}')
+MAIN_USER_VALUE=$(id -u 1000 -n)
+cat <<EOF
+°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+You can connect to this system using the
+following information:
+
+        IPv4: $IP_V4_VALUE
+        IPv6: $IP_V6_VALUE
+ sudoer user: $MAIN_USER_VALUE
+
+°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°
+EOF