From c6433201a47a41e5c938e0c7e8a4f86534786122 Mon Sep 17 00:00:00 2001 From: Jybz Date: Fri, 3 Jan 2020 11:53:36 +0100 Subject: [PATCH 1/4] Automatically set root password and user prior configuration. --- create_arm_img_urpmi.sh | 15 +++++++++++++-- platforms/bananaPro/mageia4arm.cfg | 11 ++++++----- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/create_arm_img_urpmi.sh b/create_arm_img_urpmi.sh index 880ddd1..25788be 100755 --- a/create_arm_img_urpmi.sh +++ b/create_arm_img_urpmi.sh @@ -231,8 +231,19 @@ function preparechroot() exit ${ERR_1} fi - info "creation of user account" - echo -e "/bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n /sbin/useradd ${ID_USER}\n /bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh" + info "Preparation for setting root and user account" + if [ -n "${ROOT_PWD}" ]; then #If root password defined, it will be setted at the end of the chroot of the second_stage_install.sh script + echo -e " /bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n" >>"${BUILD_PATH}/second_stage_install.sh" + else + info "No root password... One password will be set at the first login." + fi + + if [ -n "${ID_USER}" ]; then #If user ID defined, it will be setted at the end of the chroot of the second_stage_install.sh script + echo -e " /sbin/useradd ${ID_USER}\n /bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh" + else + info "No user defined, no user account created." + fi + # info "Copying skel in root directory" # /bin/rsync -rlptH "${BUILD_PATH}/etc/skel/" "${BUILD_PATH}/root/" diff --git a/platforms/bananaPro/mageia4arm.cfg b/platforms/bananaPro/mageia4arm.cfg index 0161efa..b3c2e98 100644 --- a/platforms/bananaPro/mageia4arm.cfg +++ b/platforms/bananaPro/mageia4arm.cfg @@ -54,15 +54,16 @@ BOOT="/mnt/boot" ROOT="/mnt/root" # Default user -# TO MODIFY -ID_USER="banana" -PASSWORD="bananaPro" +# If not set, no user will be defined. +# ID_USER="banana" +# PASSWORD="bananaPro" #root password -ROOT_PWD="ProR00t" +#If not set, no root password, at the first login, the system will ask for a password. +# ROOT_PWD="ProR00t" #Hostname -HOSTNAME="${TARGET}.${ID_USER}" +HOSTNAME="${TARGET}" #Filesystem of boot partitions (default ext4 raspberry pi need vfat) SEPARATE_BOOT_PARTITION=0 From 04ed6b37ee4bf1aa04c8eeb163a176f6e7195a1e Mon Sep 17 00:00:00 2001 From: Jybz Date: Fri, 3 Jan 2020 12:22:57 +0100 Subject: [PATCH 2/4] Fix no root password --- create_arm_img_urpmi.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/create_arm_img_urpmi.sh b/create_arm_img_urpmi.sh index 25788be..6fa5f69 100755 --- a/create_arm_img_urpmi.sh +++ b/create_arm_img_urpmi.sh @@ -236,6 +236,7 @@ function preparechroot() echo -e " /bin/passwd << EOF\n${ROOT_PWD}\n${ROOT_PWD}\nEOF\n" >>"${BUILD_PATH}/second_stage_install.sh" else info "No root password... One password will be set at the first login." + echo -e " /bin/passwd -d root\n /bin/passwd -e root\n" >>"${BUILD_PATH}/second_stage_install.sh" fi if [ -n "${ID_USER}" ]; then #If user ID defined, it will be setted at the end of the chroot of the second_stage_install.sh script From e05e98f7ea447a9e205ffcd1db7d93ccb8e57267 Mon Sep 17 00:00:00 2001 From: Jybz Date: Fri, 3 Jan 2020 14:47:14 +0100 Subject: [PATCH 3/4] Fix : no user password. --- create_arm_img_urpmi.sh | 7 ++++++- platforms/bananaPro/mageia4arm.cfg | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/create_arm_img_urpmi.sh b/create_arm_img_urpmi.sh index 6fa5f69..09bf4a7 100755 --- a/create_arm_img_urpmi.sh +++ b/create_arm_img_urpmi.sh @@ -240,7 +240,12 @@ function preparechroot() fi if [ -n "${ID_USER}" ]; then #If user ID defined, it will be setted at the end of the chroot of the second_stage_install.sh script - echo -e " /sbin/useradd ${ID_USER}\n /bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh" + echo -e " /sbin/useradd ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh" + if [ -n "${PASSWORD}" ]; then + echo -e " /bin/passwd ${ID_USER} << EOF\n${PASSWORD}\n${PASSWORD}\nEOF" >>"${BUILD_PATH}/second_stage_install.sh" + else + echo -e " /bin/passwd -d ${ID_USER}\n" >>"${BUILD_PATH}/second_stage_install.sh" + fi else info "No user defined, no user account created." fi diff --git a/platforms/bananaPro/mageia4arm.cfg b/platforms/bananaPro/mageia4arm.cfg index b3c2e98..a9f9867 100644 --- a/platforms/bananaPro/mageia4arm.cfg +++ b/platforms/bananaPro/mageia4arm.cfg @@ -55,7 +55,7 @@ ROOT="/mnt/root" # Default user # If not set, no user will be defined. -# ID_USER="banana" +ID_USER="banana" # PASSWORD="bananaPro" #root password From c9dbaadba7b7bf38a72ae5fbcbfe59c4ec69afec Mon Sep 17 00:00:00 2001 From: Jybz Date: Fri, 3 Jan 2020 14:47:37 +0100 Subject: [PATCH 4/4] Fix : no user password, no banana user. --- platforms/bananaPro/mageia4arm.cfg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/bananaPro/mageia4arm.cfg b/platforms/bananaPro/mageia4arm.cfg index a9f9867..b3c2e98 100644 --- a/platforms/bananaPro/mageia4arm.cfg +++ b/platforms/bananaPro/mageia4arm.cfg @@ -55,7 +55,7 @@ ROOT="/mnt/root" # Default user # If not set, no user will be defined. -ID_USER="banana" +# ID_USER="banana" # PASSWORD="bananaPro" #root password