first proto of dialog boxes, and makefile for tests

dialog
Matt C 3 years ago
parent cae0f326d5
commit 91c6e6f6a9

@ -0,0 +1,7 @@
install:
chmod +x *.sh
mv *.sh /usr/bin
mv /usr/bin/citrine.sh /usr/bin/citrine
mv /usr/bin/citrine.internal.sh /usr/bin/citrine.internal
test: install
citrine

@ -14,6 +14,26 @@ prompt() {
read response
}
# ---------------------------------
yn=""
yesno() {
dialog --title Citrine --yesno "$@" 10 80
yn="$?"
}
dumptitle=""
dump() {
dialog --title $dumptitle --no-collapse --msgbox "$@" 0 0
}
msgdat=""
msgbox(){
dialog --title Citrine --inputbox "$@" 10 80 2>tmp
msgdat=$(cat tmp)
rm tmp
}
# --------------------------
if [[ "$EUID" != "0" ]]; then
err "Run as root"
exit 1
@ -24,10 +44,12 @@ pacman-key --init
pacman-key --populate archlinux
pacman-key --populate crystal
prompt "Do you need a keyboard layout other than standard US? (y/N)"
KBD="$response"
yesno "Do you need a keyboard layout other than QWERTY US?"
KBD="$yn"
echo "KBD=$response"
if [[ "$KBD" == "y" || "$KBD" == "Y" ]]; then
# TODO: layout select in dialog
if [[ "$KBD" == "0" || "$KBD" == "0" ]]; then
prompt "We're going to show the list of keymaps in less. Do you know how to exit less? (Y/n)"
UL="$response"
if [[ "$UL" == "n" ]]; then
@ -44,23 +66,24 @@ fi
clear
inf "Disks:"
fdisk -l | grep Disk | grep sectors --color=never
prompt "Would you like to partition manually? (y/N)"
yesno "Would you like to partition manually?"
echo "PMODE=$response"
PMODE="$response"
PMODE="$yn"
dumptitle="System Disks"
dump "$(fdisk -l | grep Disk | grep sectors --color=never)"
MANUAL="no"
DISK=""
if [[ "$PMODE" == "y" ]]; then
if [[ "$PMODE" == "0" ]]; then
MANUAL="yes"
else
prompt "Install target WILL BE FULLY WIPED"
echo "DISK=$response"
DISK="$response"
msgbox "Install target WILL BE FULLY WIPED"
echo "DISK=$msgdat"
DISK="$msgdat"
if ! fdisk -l ${DISK}; then
err "Seems like $DISK doesn't exist. Did you typo?"
dumptitle="ERROR"
dump "Seems like $DISK doesn't exist. Did you typo?"
exit 1
fi
fi
@ -81,16 +104,21 @@ else
fi
echo "EFI=$EFI"
dumptitle="Please confirm"
if [[ "$EFI" == "yes" ]]; then
prompt "This PC seems to have booted with UEFI. Press enter to confirm"
dump "This PC seems to *have* booted with UEFI. Press enter to confirmor Control+C to cancel"
else
prompt "This PC seems to *not* have booted with UEFI. Press enter to aknowledge, or press Control+C if this seems wrong."
dump "This PC seems to *not* have booted with UEFI. Press enter to aknowledge, or press Control+C if this seems wrong."
fi
inf "Setting system clock via network"
timedatectl set-ntp true
if [[ "$MANUAL" == "no" ]]; then
dumptitle="CAUTION!"
dump "This is your last chance to avoid deleting critical data on $DISK. If you're not sure, press Control+C NOW!"
echo "Partitioning disk"
if [[ "$EFI" == "yes" ]]; then
parted ${DISK} mklabel gpt --script
@ -132,30 +160,34 @@ if [[ "$MANUAL" == "no" ]]; then
fi
else
clear
inf "You have chosen manual partitioning."
inf "We're going to drop to a shell for you to partition, but first, PLEASE READ these notes."
inf "Before you exit the shell, make sure to format and mount a partition for / at /mnt"
dumptitle="Read carefully."
dump "You have chosen manual partitioning.\
We're going to drop to a shell for you to partition, but first, PLEASE READ these notes.\
Before you exit the shell, make sure to format and mount a partition for / at /mnt."
if [[ "$EFI" == "yes" ]]; then
mkdir -p /mnt/efi
inf "Additionally, since this machine was booted with UEFI, please make sure to make a 200MB or greater partition"
inf "of type VFAT and mount it at /mnt/efi"
dump "Additionally, since this machine was booted with UEFI, please make sure to make a 200MB or greater partition\
of type VFAT and mount it at /mnt/efi"
else
inf "Please give me the full path of the device you're planning to partition (needed for bootloader installation later)"
inf "Example: /dev/sda"
printf ": "
read DISK
msgbox "Please give me the full path of the device you're planning to partition (needed for bootloader installation later)\
.. Example: /dev/sda"
DISK="${msgdat}"
fi
CONFDONE="NOPE"
dumptitle="Citrine"
while [[ "$CONFDONE" == "NOPE" ]]; do
inf "Press enter to go to a shell."
read
bash
prompt "All set (and partitions mounted?) (y/N)"
echo "STAT=$response"
STAT="$response"
if [[ "$STAT" == "y" ]]; then
dump "Press enter to go to a shell. (ZSH)"
zsh
yesno "All set (and partitions mounted?)"
echo "STAT=$yn"
STAT="$yn"
if [[ "$STAT" == "0" ]]; then
if ! findmnt | grep /mnt; then
err "Are you sure you've mounted the partitions?"
@ -170,7 +202,8 @@ inf "Verifying network connection"
ping -c 1 getcryst.al
if [[ ! "$?" == "0" ]]; then
err "It seems like this system can't reach the internet. Exiting."
dumptitle="Error!"
dump "It seems like this system can't reach the internet. Exiting."
exit 1
fi
@ -209,6 +242,7 @@ fi
arch-chroot /mnt /continue.sh 2>&1 | tee /mnt/var/log/citrine.chroot.log
rm /mnt/continue.sh
inf "Installation should now be complete."
read
dumptitle="Citrine"
dump "Installation should now be complete."
#read

@ -14,10 +14,30 @@ prompt() {
read response
}
# ---------------------------------
yn=""
yesno() {
dialog --title Citrine --yesno "$@" 10 80
yn="$?"
}
dumptitle=""
dump() {
dialog --title $dumptitle --no-collapse --msgbox "$@" 0 0
}
msgdat=""
msgbox(){
dialog --title Citrine --inputbox "$@" 10 80 2>tmp
msgdat=$(cat tmp)
rm tmp
}
# --------------------------
clear
TZ="/usr/share/LMAO/XD"
while [[ ! -f $TZ ]]; do
prompt "Pick a time zone (Format: America/New_York , Europe/London, etc)"
msgbox "Pick a time zone (Format: America/New_York , Europe/London, etc)"
PT="$response"
TZ="/usr/share/zoneinfo/${PT}"
done
@ -31,21 +51,21 @@ echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" > /etc/locale.conf
clear
prompt "Do you need more locales than just en_US? (y/N)"
echo "MORE=$response"
MORE="$response"
if [[ "$MORE" == "y" || "$MORE" == "Y" ]]; then
prompt "Preferred editor"
PGRM="$response"
echo "PGRM=$response"
yesno "Do you need more locales than just en_US?"
echo "MORE=$yn"
MORE="$yn"
if [[ "$MORE" == "0" ]]; then
msgbox "Preferred editor"
PGRM="$msgdat"
echo "PGRM=$msgdat"
if [[ -x "$(command -v ${PGRM})" ]]; then
inf "Attempting to install ${PGRM}"
pacman -Sy ${PGRM} --noconfirm
fi
inf "When we open the file, please remove the leading # before any locales you need."
inf "Then, save and exit.\nPress enter."
read
dumptitle="Read carefully."
dump "When we open the file, please remove the leading # before any locales you need.\
Then, save and exit."
${PGRM} /etc/locale.gen
fi
@ -67,19 +87,21 @@ if [[ -f /keymap ]]; then
fi
clear
prompt "System hostname"
HOSTNAME="$response"
msgbox "Enter the system hostname"
HOSTNAME="$msgdat"
echo ${HOSTNAME} > /etc/hostname
echo "127.0.0.1 localhost" > /etc/hosts
prompt "Would you like IPV6? (y/N)"
IPS="$response"
if [[ "$IPS" == "y" || "$IPS" == "Y" ]]; then
yesno "Would you like IPV6?"
IPS="$yn"
if [[ "$IPS" == "0" ]]; then
echo "::1 localhost" >> /etc/hosts
fi
echo "127.0.1.1 ${HOSTNAME}.localdomain ${HOSTNAME}" >> /etc/hosts
clear
inf "Password for root"
inf "Set a password for root"
done="nope"
while [[ "$done" == "nope" ]]; do
passwd
@ -88,8 +110,8 @@ while [[ "$done" == "nope" ]]; do
fi
done
prompt "Your username"
UN="$response"
msgbox "Your username"
UN="$msgdat"
useradd -m ${UN}
usermod -aG wheel ${UN}
inf "Set password for ${UN}"
@ -124,34 +146,33 @@ pacman-key --populate crystal
clear
prompt "Would you like to install a DE/WM profile? (y/N)"
echo "DEP=$response"
DEP="$response"
if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then
inf "--- Desktop Environments ---"
inf "- Budgie"
inf "- Cinnamon"
inf "- Deepin"
inf "- Enlightenment (note: very DIY. Read Arch Wiki)"
inf "- GNOME"
# Flashback seems to need some work
#inf "- (GNOME) Flashback"
inf "- KDE"
inf "- LXDE"
inf "- LXQt"
inf "- Mate"
inf "- Cutefish"
inf "- Xfce"
inf "- UKUI (note: very poorly documented. In english, anyway)"
inf "--- Window Managers ---"
inf "- i3"
inf "(We'll add more as people ask)"
inf "Please enter exactly as shown."
prompt ""
echo "DE=$response"
DE="$response"
yesno "Would you like to install a DE/WM profile?"
echo "DEP=$yn"
DEP="$yn"
if [[ "$DEP" == "0" ]]; then
dumptitle="Desktop/WM Choices"
dump "\
--- Desktop Environments ---
- Budgie
- Cinnamon
- Deepin
- GNOME
- KDE
- LXDE
- LXQt
- Mate
- Xfce"
msgbox "DE Choice (please enter exactly)"
echo "DE=$msgdat"
DE="$msgdat"
DM=""
if [[ "$DE" == "Budgie" ]]; then
pacman -Sy --quiet --noconfirm budgie-desktop gnome
DM="gdm"
@ -161,15 +182,9 @@ if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then
elif [[ "$DE" == "Deepin" ]]; then
pacman -Sy --quiet --noconfirm deepin deepin-extra
DM="lightdm"
elif [[ "$DE" == "Enlightenment" ]]; then
pacman -Sy --quiet --noconfirm enlightenment terminology
elif [[ "$DE" == "GNOME" ]]; then
pacman -Sy --quiet --noconfirm gnome gnome-extra chrome-gnome-shell
DM="gdm"
elif [[ "$DE" == "Flashback" || "$DE" == "GNOME Flashback" || "$DE" == "(GNOME) Flashback" ]]; then
DE="Flashback"
pacman -Sy --quiet --noconfirm gnome-flashback gnome-backgrounds gnome-control-center network-manger-applet gnome-applets sensors-applet
DM="gdm"
elif [[ "$DE" == "KDE" ]]; then
pacman -Sy --quiet --noconfirm plasma kde-applications sddm
DM="sddm"
@ -182,47 +197,17 @@ if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then
elif [[ "$DE" == "Mate" ]]; then
pacman -Sy --quiet --noconfirm mate mate-extra mate-applet-dock mate-applet-streamer
DM="gdm"
elif [[ "$DE" == "UKUI" ]]; then
pacman -Sy --quiet --noconfirm ukui
elif [[ "$DE" == "Xfce" ]]; then
pacman -Sy --quiet --noconfirm xfce4 xfce4-goodies
DM="sddm"
elif [[ "$DE" == "Cutefish" || "$DE" == "cutefish" ]] ;then
pacman -Sy --quiet --noconfirm cutefish
DM="sddm"
# Start WM's
elif [[ "$DE" == "i3" ]]; then
inf "Choose either i3 or i3-gaps in below prompt. Rest of group is your preference"
inf "Press enter"
prompt ""
pacman -Sy i3 xorg-xinit xorg-server
fi
if [[ "$DM" == "" ]]; then
inf "Your selected DE/WM doesn't have a standard display manager. Enter one of the below names, or leave blank for none"
inf "- gdm"
inf "- sddm"
inf "- lightdm (you'll need a greeter package. See Arch Wiki)"
inf "- (you can type another Arch package name if you have one in mind)"
inf "- [blank] for none"
prompt ""
ND="$response"
echo "ND=$ND"
if [[ "$ND" != "" ]]; then
inf "Ok, we'll install $ND"
DM="$ND"
pacman -Sy --quiet --noconfirm $DM
else
inf "Ok, not installing a display manager."
fi
else
pacman -Sy --quiet --noconfirm $DM
fi
if [[ "$DM" != "" ]]; then
prompt "Would you like to enable ${DM} for ${DE}? (Y/n)"
useDM="$response"
if [[ "$useDM" != "n" ]]; then
yesno "Would you like to enable ${DM} for ${DE}?"
useDM="$yn"
if [[ "$useDM" == "0" ]]; then
systemctl enable ${DM}
if [[ "$DE" == "Deepin" ]]; then
sed -i 's/lightdm-gtk-greeter/lightdm-deepin-greeter/g' /etc/lightdm/lightdm.conf
@ -231,19 +216,19 @@ if [[ "$DEP" == "y" || "$DEP" == "Y" ]]; then
fi
fi
prompt "Would you like to add more packages? (Y/n)"
MP="$response"
if [[ "$MP" != "n" ]]; then
prompt "Would you like to use a URL to a package list? (Y/n)"
OL="$response"
if [[ "$OL" == "n" ]]; then
prompt "Write package names"
PKGNS="$response"
yesno "Would you like to add more packages?"
MP="$yn"
if [[ "$MP" == "0" ]]; then
yesno "Would you like to use a URL to a package list?"
OL="$yesno"
if [[ "$OL" != "0" ]]; then
msgbox "Package names"
PKGNS="$msgdat"
inf "Installing: $PKGNS"
ame -S ${PKGNS}
else
prompt "URL to package list"
SRC="$response"
msgbox "URL to package list"
SRC="$msgdat"
PKGS="$(curl ${SRC})"
for PKG in PKGS; do
ame -S ${PKG}
@ -251,4 +236,4 @@ if [[ "$MP" != "n" ]]; then
fi
fi
inf "Installation complete"
#inf "Installation complete"

Loading…
Cancel
Save