瀏覽代碼

Reformat of displayed messages

Laurent HUBERT 6 年之前
父節點
當前提交
ef75a88d79
共有 6 個文件被更改,包括 38 次插入47 次删除
  1. 6 8
      scripts/01-renew-ssh-keys
  2. 6 10
      scripts/02-password
  3. 6 10
      scripts/03-user-password
  4. 10 12
      scripts/04-create-default-user
  5. 6 4
      scripts/50-hostname
  6. 4 3
      scripts/skeleton

+ 6 - 8
scripts/01-renew-ssh-keys

@@ -5,9 +5,9 @@
 # Renews the ssh server keys if they exist
 # Renews the ssh server keys if they exist
 #
 #
 cat <<EOF
 cat <<EOF
-##################################
-# Renewing SSH server keys       #
-##################################
++---------------------------------------------+
+| Renewing SSH server keys                    |
++---------------------------------------------+
 EOF
 EOF
 status=0
 status=0
 renew_ssh_keys(){
 renew_ssh_keys(){
@@ -20,11 +20,9 @@ ls /etc/ssh/ssh_host_*key* > /dev/null 2>&1 && renew_ssh_keys || status=1
 if [ 0 -ne "$status" ]
 if [ 0 -ne "$status" ]
 then
 then
   # Exit with non zero status
   # Exit with non zero status
-  echo "Error renewing SSH keys"
+  echo "### Error renewing SSH keys    ###"
   exit 1
   exit 1
 else
 else
-  cat <<-EOF
-# Renewing SSH server keys: OK   #
-##################################
-EOF
+  echo "> Renewing SSH server keys : OK               <"
+  exit 0
 fi
 fi

+ 6 - 10
scripts/02-password

@@ -5,9 +5,9 @@
 # Changes the root password
 # Changes the root password
 #
 #
 cat <<EOF
 cat <<EOF
-##################################
-# Changing super-user password   #
-##################################
++---------------------------------------------+
+| Changing super-user password                |
++---------------------------------------------+
 EOF
 EOF
 status=1
 status=1
 
 
@@ -17,17 +17,13 @@ do
   status=$?
   status=$?
   if [ 0 -ne "$status" ]
   if [ 0 -ne "$status" ]
   then
   then
-    echo "Error changing super-user password"
+    echo "### Error changing super-user password ###"
     echo "Please try again"
     echo "Please try again"
   else
   else
-    cat <<EOF
-**********************************
-* super-user password : changed  *
-**********************************
-EOF
+    echo "> super-user password : changed           <"
     exit 0
     exit 0
   fi
   fi
 done
 done
 
 
-echo "An error occurred changing super-user password"
+echo "### An error occurred changing super-user password   ###"
 exit $status
 exit $status

+ 6 - 10
scripts/03-user-password

@@ -7,9 +7,9 @@
 # Default user should have id 1000:
 # Default user should have id 1000:
 the_user=$(id -u 1000 -n)
 the_user=$(id -u 1000 -n)
 cat <<EOF
 cat <<EOF
-##################################
-# Changing $the_user password #
-##################################
++---------------------------------------------+
+| Changing $the_user password                 |
++---------------------------------------------+
 EOF
 EOF
 status=1
 status=1
 while [ 0 -ne "$status" ]
 while [ 0 -ne "$status" ]
@@ -18,17 +18,13 @@ do
   status=$?
   status=$?
   if [ 0 -ne "$status" ]
   if [ 0 -ne "$status" ]
   then
   then
-    echo "Error changing $the_user password"
+    echo "### Error changing $the_user password   ###"
     echo "Please try again"
     echo "Please try again"
   else
   else
-    cat <<EOF
-**********************************
-* $the_user password : changed  *
-**********************************
-EOF
+    echo "> $the_user password : changed  <"
     exit 0
     exit 0
   fi
   fi
 done
 done
 
 
-echo "An error occurred changing $the_user password"
+echo "### An error occurred changing $the_user password   ###"
 exit $status
 exit $status

+ 10 - 12
scripts/04-create-default-user

@@ -5,9 +5,9 @@
 # Creates a new user for administrative purposes (in sudo group)
 # Creates a new user for administrative purposes (in sudo group)
 #
 #
 cat <<EOF
 cat <<EOF
-##################################
-# Creating default user          #
-##################################
++---------------------------------------------+
+| Creating default user                       |
++---------------------------------------------+
 EOF
 EOF
 read -p "Please enter default user name: " the_user
 read -p "Please enter default user name: " the_user
 
 
@@ -24,9 +24,11 @@ fi
 
 
 if [ 0 -ne "$status" ]
 if [ 0 -ne "$status" ]
 then
 then
-  echo "Error creating $the_user"
-  echo "Please try again by rebooting"
+  echo "### Error creating $the_user   ###"
+  echo "### Please try again by rebooting your system  ###"
+  exit 1
 else
 else
+  # Adds new user to sudo group
   adduser $the_user sudo
   adduser $the_user sudo
 fi
 fi
 
 
@@ -37,17 +39,13 @@ do
   status=$?
   status=$?
   if [ 0 -ne "$status" ]
   if [ 0 -ne "$status" ]
   then
   then
-    echo "Error changing $the_user password"
+    echo "# Error changing $the_user password   #"
     echo "Please try again"
     echo "Please try again"
   else
   else
-    cat <<EOF
-************************************
-* $the_user : created successfully *
-************************************
-EOF
+    echo "> $the_user : created successfully <"
     exit 0
     exit 0
   fi
   fi
 done
 done
 
 
-echo "An error occurred changing $the_user password"
+echo "### An error occurred changing $the_user password   ###"
 exit $status
 exit $status

+ 6 - 4
scripts/50-hostname

@@ -5,21 +5,23 @@
 # Changes the machine hostname
 # Changes the machine hostname
 #
 #
 cat <<EOF
 cat <<EOF
-##############################
-# Changing hostname          #
-##############################
++---------------------------------------------+
+| Changing hostname                           |
++---------------------------------------------+
 EOF
 EOF
 read -p "Please enter new hostname: " answer
 read -p "Please enter new hostname: " answer
 
 
 if [ -n "$answer" ]
 if [ -n "$answer" ]
 then
 then
-  echo Changing hostname to $answer
+  echo "Changing hostname to $answer"
   current=$(hostname)
   current=$(hostname)
   sed -i.firstboot.backup s/$current/$answer/g /etc/hostname
   sed -i.firstboot.backup s/$current/$answer/g /etc/hostname
   sed -i.firstboot.backup s/$current/$answer/g /etc/hosts
   sed -i.firstboot.backup s/$current/$answer/g /etc/hosts
   hostname $answer
   hostname $answer
+  echo "> Hostname changed to $answer <"
   exit 0
   exit 0
 else
 else
   # Exit with non zero status
   # Exit with non zero status
+  echo "### Could not change hostname   ###"
   exit 1
   exit 1
 fi
 fi

+ 4 - 3
scripts/skeleton

@@ -10,9 +10,9 @@
 #
 #
 # Example Section : Displaying a banner
 # Example Section : Displaying a banner
 cat <<EOF
 cat <<EOF
-##############################
-# My Banner                  #
-##############################
++---------------------------------------------+
+| My Banner                                   |
++---------------------------------------------+
 EOF
 EOF
 # Example Section : asking user to enter a value
 # Example Section : asking user to enter a value
 read -p "Please enter a value: " answer
 read -p "Please enter a value: " answer
@@ -25,5 +25,6 @@ then
   exit 0
   exit 0
 else
 else
   # Exit with non zero status
   # Exit with non zero status
+  echo "### Explicit error message   ###"
   exit 1
   exit 1
 fi
 fi