From c42b0af8fea562dc1dae0e865aa0721ab4c02861 Mon Sep 17 00:00:00 2001 From: TuDatTr Date: Sun, 24 May 2020 09:02:28 +0200 Subject: [PATCH] Added password for user --- install.sh | 10 +++++++--- root/march-chroot.sh | 13 +++++++++---- root/march-reboot.sh | 22 ++++++++-------------- 3 files changed, 24 insertions(+), 21 deletions(-) diff --git a/install.sh b/install.sh index c37d560..210fb22 100755 --- a/install.sh +++ b/install.sh @@ -7,8 +7,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then exit 1 fi -OPTIONS=d:t:l:h:u:s: -LONGOPTS=device:,timezone:,locale:,hostname:,username:,sudogrp:,help +OPTIONS=d:t:l:h:u:s:p: +LONGOPTS=device:,timezone:,locale:,hostname:,username:,sudogrp:,help,password: ! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then @@ -47,6 +47,10 @@ while true; do username="$2" shift 2 ;; + -p|--password) + password="$2" + shift 2 + ;; -s|--sudogrp) sudogrp="$2" shift 2 @@ -127,7 +131,7 @@ cp $CWD/etc/X11/xorg.conf.d/30-touchpad.conf /mnt/root/etc/X11/xorg.conf.d/30-to cp $CWD/etc/iptables/iptables.rules /mnt/root/etc/iptables/iptables.rules chmod +x /mnt/root/march-reboot.sh -arch-chroot /mnt /root/march-chroot.sh -t "$timezone" -l "$locale" -h "$hostname" -u "$username" -s "$sudogrp" -c "$cryptroot" -r "$rootpart" +arch-chroot /mnt /root/march-chroot.sh -t "$timezone" -l "$locale" -h "$hostname" -u "$username" -s "$sudogrp" -c "$cryptroot" -r "$rootpart" -p "$password" umount $bootpart swapoff $swappart diff --git a/root/march-chroot.sh b/root/march-chroot.sh index c1778f6..a492399 100644 --- a/root/march-chroot.sh +++ b/root/march-chroot.sh @@ -7,8 +7,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then exit 1 fi -OPTIONS=t:l:h:u:s:r:c: -LONGOPTS=timezone:,locale:,hostname:,username:,sudogrp:,rootpart:,cryptroot: +OPTIONS=t:l:h:u:s:r:c:p: +LONGOPTS=timezone:,locale:,hostname:,username:,sudogrp:,rootpart:,cryptroot:,password: ! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then @@ -23,11 +23,16 @@ username="CHANGEME" # specified in ./march-chroot.sh sudogrp="CHANGEME" # specified in ./march-chroot.sh rootpart="CHANGEME" # specified in ./march-chroot.sh cryptroot="CHANGEME" # specified in ./march-chroot.sh +password="CHANGEME" # specified in ./march-chroot.sh CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" while true; do case "$1" in + -p|--password) + password="$2" + shift 2 + ;; -t|--timezone) timezone="$2" shift 2 @@ -50,7 +55,7 @@ while true; do ;; --help) echo " -Usage: ./install.sh -d [DEVICE] -t [/usr/share/zoneinfo/REGION/CITY] -l [LOCALE] -h [HOSTNAME] -u [USER] -s [SUDO] + Usage: ./install.sh -d [DEVICE] -t [/usr/share/zoneinfo/REGION/CITY] -l [LOCALE] -h [HOSTNAME] -u [USER] -s [SUDO] A small script to automate my archlinux configuration. Mandatory arguments: @@ -111,7 +116,7 @@ linux /vmlinuz-linux initrd /initramfs-linux.img options rw cryptdevice=$(blkid $rootpart | cut -d" " -f2 | tr -d \"):cryptroot root=$cryptroot i8042.noloop i8042.nomux i8042.nopnp i8042.reset" > /boot/loader/entries/arch.conf -sed -i "s/march-reboot.sh/\0 -u \"$username\" -s \"$sudogrp\"/" /etc/systemd/system/march.service +sed -i "s/march-reboot.sh/\0 -u \"$username\" -s \"$sudogrp\" -p \"$password\"/" /etc/systemd/system/march.service systemctl enable march.service systemctl enable NetworkManager.service diff --git a/root/march-reboot.sh b/root/march-reboot.sh index cd4e10b..0e79d84 100644 --- a/root/march-reboot.sh +++ b/root/march-reboot.sh @@ -7,8 +7,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then exit 1 fi -OPTIONS=u:s: -LONGOPTS=username:,sudogrp: +OPTIONS=u:s:p: +LONGOPTS=username:,sudogrp:,password: ! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then @@ -17,28 +17,21 @@ fi eval set -- "$PARSED" username="CHANGEME" +password="CHANGEME" sudogrp="CHANGEME" CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" while true; do case "$1" in - -t|--timezone) - timezone="$2" - shift 2 - ;; - -l|--locale) - locale="$2" - shift 2 - ;; - -h|--hostname) - hostname="$2" - shift 2 - ;; -u|--username) username="$2" shift 2 ;; + -p|--password) + password="$2" + shift 2 + ;; -s|--sudogrp) sudogrp="$2" shift 2 @@ -61,6 +54,7 @@ pacman -S --noconfirm git zsh gvim wget arch-audit lightdm lightdm-webkit2-greet echo "%$sudogrp ALL=(ALL) ALL" >> /etc/sudoers groupadd "$sudogrp" useradd -m -G "$sudogrp" -s /bin/zsh "$username" +echo "$username:$password" | chpasswd systemctl enable lightdm sed -i "s/#user-session.*/user-session=i3/g" /etc/lightdm/lightdm.conf