Merge pull request #135 from mfgbhatti/test
Added more control on setup.conf in startup.sh
This commit is contained in:
commit
c870af9808
14
1-setup.sh
14
1-setup.sh
|
|
@ -48,12 +48,12 @@ echo -ne "
|
|||
"
|
||||
sed -i 's/^#en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
|
||||
locale-gen
|
||||
timedatectl --no-ask-password set-timezone ${timezone}
|
||||
timedatectl --no-ask-password set-timezone ${TIMEZONE}
|
||||
timedatectl --no-ask-password set-ntp 1
|
||||
localectl --no-ask-password set-locale LANG="en_US.UTF-8" LC_TIME="en_US.UTF-8"
|
||||
|
||||
# Set keymaps
|
||||
localectl --no-ask-password set-keymap ${keymap}
|
||||
localectl --no-ask-password set-keymap ${KEYMAP}
|
||||
|
||||
# Add sudo no password rights
|
||||
sed -i 's/^# %wheel ALL=(ALL) NOPASSWD: ALL/%wheel ALL=(ALL) NOPASSWD: ALL/' /etc/sudoers
|
||||
|
|
@ -151,13 +151,13 @@ echo -ne "
|
|||
-------------------------------------------------------------------------
|
||||
"
|
||||
if [ $(whoami) = "root" ]; then
|
||||
useradd -m -G wheel,libvirt -s /bin/bash $username
|
||||
useradd -m -G wheel,libvirt -s /bin/bash $USERNAME
|
||||
# use chpasswd to enter $username:$password
|
||||
echo "$username:$password" | chpasswd
|
||||
cp -R /root/$SCRIPTHOME /home/$username/
|
||||
chown -R $username: /home/$username/$SCRIPTHOME
|
||||
echo "$USERNAME:$PASSWORD" | chpasswd
|
||||
cp -R /root/$SCRIPTHOME /home/$USERNAME/
|
||||
chown -R $USERNAME: /home/$USERNAME/$SCRIPTHOME
|
||||
# enter $hostname to /etc/hostname
|
||||
echo $hostname > /etc/hostname
|
||||
echo $HOSTNAME > /etc/hostname
|
||||
else
|
||||
echo "You are already a user proceed with aur installs"
|
||||
fi
|
||||
|
|
|
|||
94
startup.sh
94
startup.sh
|
|
@ -1,5 +1,21 @@
|
|||
#!/usr/bin/env bash
|
||||
# This script will ask users about their prefrences like disk, file system,
|
||||
# This script will ask users about their prefrences
|
||||
# like disk, file system, timezone, keyboard layout,
|
||||
# user name, password, etc.
|
||||
|
||||
# set up a config file
|
||||
CONFIG_FILE=setup.conf
|
||||
if [ ! -f $CONFIG_FILE ]; then # check if file exists
|
||||
touch -f $CONFIG_FILE # create file if not exists
|
||||
fi
|
||||
|
||||
# set options in setup.conf
|
||||
set_option() {
|
||||
if grep -Eq "^${1}.*" $CONFIG_FILE; then # check if option exists
|
||||
sed -i -e "/^${1}.*/d" $CONFIG_FILE # delete option if exists
|
||||
fi
|
||||
echo "${1}=${2}" >>$CONFIG_FILE # add option
|
||||
}
|
||||
logo () {
|
||||
# This will be shown on every set as user is progressing
|
||||
echo -ne "
|
||||
|
|
@ -27,13 +43,13 @@ echo -ne "
|
|||
"
|
||||
read FS
|
||||
case $FS in
|
||||
1) echo "FS=btrfs" >> setup.conf;;
|
||||
2) echo "FS=ext4" >> setup.conf;;
|
||||
1) set_option FS btrfs;;
|
||||
2) set_option FS ext4;;
|
||||
3)
|
||||
echo -ne "Please enter your luks password: "
|
||||
read luks_password
|
||||
echo "luks_password=$luks_password" >> setup.conf
|
||||
echo "FS=luks" >> setup.conf;;
|
||||
read -s luks_password # read password without echo
|
||||
set_option luks_password $luks_password
|
||||
set_option FS luks;;
|
||||
0) exit ;;
|
||||
*) echo "Wrong option please select again"; filesystem;;
|
||||
esac
|
||||
|
|
@ -41,16 +57,16 @@ esac
|
|||
timezone () {
|
||||
# Added this from arch wiki https://wiki.archlinux.org/title/System_time
|
||||
time_zone="$(curl --fail https://ipapi.co/timezone)"
|
||||
echo -ne "System detected your timezone to be '$time_zone'"
|
||||
echo -ne "System detected your timezone to be '$time_zone' \n"
|
||||
echo -ne "Is this correct? yes/no:"
|
||||
read answer
|
||||
case $answer in
|
||||
y|Y|yes|Yes|YES)
|
||||
echo "timezone=$time_zone" >> setup.conf;;
|
||||
set_option TIMEZONE $time_zone;;
|
||||
n|N|no|NO|No)
|
||||
echo "Please enter your desired timezone e.g. Europe/London :"
|
||||
read new_timezone
|
||||
echo "timezone=$new_timezone" >> setup.conf;;
|
||||
set_option TIMEZONE $new_timezone;;
|
||||
*) echo "Wrong option. Try again";timezone;;
|
||||
esac
|
||||
}
|
||||
|
|
@ -88,10 +104,13 @@ Please select key board layout from this list
|
|||
|
||||
"
|
||||
read -p "Your key boards layout:" keymap
|
||||
echo "keymap=$keymap" >> setup.conf
|
||||
set_option KEYMAP $keymap
|
||||
}
|
||||
|
||||
# selection for disk type
|
||||
diskpart () {
|
||||
lsblk
|
||||
# show disks present on system
|
||||
lsblk -n --output TYPE,KNAME | awk '$1=="disk"{print NR,"/dev/"$2}' # show disks with /dev/ prefix
|
||||
echo -ne "
|
||||
------------------------------------------------------------------------
|
||||
THIS WILL FORMAT AND DELETE ALL DATA ON THE DISK
|
||||
|
|
@ -99,25 +118,54 @@ echo -ne "
|
|||
after formating your disk there is no way to get data back
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Please enter disk to work on: (example /dev/sda):
|
||||
Please enter full path to disk: (example /dev/sda):
|
||||
"
|
||||
read option
|
||||
echo "DISK=$option" >> setup.conf
|
||||
set_option DISK $option
|
||||
}
|
||||
userinfo () {
|
||||
echo -ne "Please enter username: "
|
||||
read username
|
||||
echo "username=$username" >> setup.conf
|
||||
echo -ne "Please enter your password: "
|
||||
read password
|
||||
echo "password=$password" >> setup.conf
|
||||
echo -ne "Please enter your hostname: "
|
||||
read hostname
|
||||
echo "hostname=$hostname" >> setup.conf
|
||||
read -p "Please enter your username: " username
|
||||
set_option USERNAME ${username,,} # convert to lower case as in issue #109
|
||||
echo -ne "Please enter your password: \n"
|
||||
read -s password # read password without echo
|
||||
set_option PASSWORD $password
|
||||
read -rep "Please enter your hostname: " hostname
|
||||
set_option HOSTNAME $hostname
|
||||
}
|
||||
# More features in future
|
||||
# language (){}
|
||||
rm -rf setup.conf &>/dev/null
|
||||
network (){
|
||||
echo -ne "
|
||||
Make sure your wifi device is active from the bios settings.
|
||||
You can also use rfkill to device listing. This script
|
||||
support only wifi connections.
|
||||
"
|
||||
iwctl device list # list devices present
|
||||
read -p "Select interface for connecting: " WLAN
|
||||
iwctl station $WLAN scan
|
||||
sleep 1
|
||||
echo "Getting network."
|
||||
sleep 1
|
||||
echo "Getting network.."
|
||||
sleep 1
|
||||
echo "Getting network..."
|
||||
iwctl station $WLAN get-networks
|
||||
read -p "Enter SSID to connect: " SSID
|
||||
echo "Enter network passphrase: \n"
|
||||
read -s PASS
|
||||
iwctl --passphrase '$PASS' station '$WLAN' connect '$SSID'
|
||||
echo "Checking connection"
|
||||
|
||||
if ping -c 1 archlinux.org &>/dev/null; then
|
||||
echo "Hurray!! You are connected."
|
||||
else
|
||||
echo "There is something this script cannot deal with!"
|
||||
fi
|
||||
}
|
||||
# Starting functions
|
||||
network
|
||||
clear
|
||||
logo
|
||||
userinfo
|
||||
clear
|
||||
logo
|
||||
|
|
|
|||
Loading…
Reference in New Issue