From bdd706ec26da6df4ae0a7a9482d5c61528fa54d4 Mon Sep 17 00:00:00 2001 From: JKANetwork Date: Sun, 12 Feb 2017 23:29:12 +0100 Subject: [PATCH] Trying things --- installer/installer.sh | 67 ++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/installer/installer.sh b/installer/installer.sh index a0d23d2..2b08f1b 100755 --- a/installer/installer.sh +++ b/installer/installer.sh @@ -1,27 +1,70 @@ #!/bin/bash ## Note: Some text editors in some lines its wrong the "markup color" because much '"'($) things. +## This function runs (non interactive) commands, and have various arguments, and logs it in $log file +## $1 -> Sentence to show +## $2 -> If it has to be silent (0->Show, 1/not 0->Silent) +## $3 -> Where to run (sudo: sudo $3, chroot: in the chroot as root, chuser: in chroot as the created user +## $4 -> Command to run +## $5 -> Is a "various-sentence command"? (1 -> First / Not lastest, 2 -> Last ) +function comm { + # First complete the command, if necessary + if [[ $3 == "chroot" ]];then + $4 = "chroot /mnt /bin/bash -c \"$4\"" + else if [[ $3 == "chuser" ]];then + $4 = "chroot /mnt /bin/bash -c \"su $nameuser -c \"$4\" \" " + fi + + # Make silent if it has to be + if [[ $2 != "0" ]];then + $4 = "$4 >/dev/null" + fi + + # Check for multisentence command and run + if [[ $multiSentence == "0" ]];then + echo "[ RUNNING ] $1" + fi + #Run command. (Command is $4) + $4 + + # Update multiSentence var + if [[ $5 == "1" ]] + multiSentence="1" + fi + if [[ $5 == "2" ]] + multiSentence="0" + fi + + # When command finish, know if it ran succesfully + if [[ $? != "0" ]];then + echo "[ ERROR ] $1" + echo "[ ERROR ] $1" >> /tmp/install.log + fi + + if [[ $? == "0" && $5 != "1" ]] + echo "[ OK ] $1" + echo "[ OK ] $1" >> /tmp/install.log + fi + +} + + if [[ ! -f "jkarch" ]];then #Prepare system before install dialog --title "JKArch install script" --msgbox "Starting installation, please wait" 15 60 # First add exec permisson to me chmod +x installer.sh # Grow cowspace - echo "[ RUN ] Grow cowspace for installer" - sudo -S mount -o remount,size=700M /run/archiso/cowspace - echo "[ OK ] Grow cowspace for installer" + comm "Grow cowspace for installer" "1" "sudo" "mount -o remount,size=700M /run/archiso/cowspace" #Enable pacman - echo "[ RUN ] Configuring pacman" - sudo pacman-key --init >/dev/null - sudo pacman-key --populate >/dev/null - sudo pacman -Sy archlinux-keyring --noconfirm - echo "[ OK ] Configuring pacman" + comm "Configuring pacman" "1" "sudo" "pacman-key --init" "1" + comm "Configuring pacman" "1" "sudo" "pacman-key --populate" "1" + comm "Configuring pacman" "1" "sudo" "pacman -Sy archlinux-keyring --noconfirm" "2" + + comm "Selecting mirrors" "1" "sudo" "pacman -S reflector --noconfirm" "1" + comm "Selecting mirrors" "1" "sudo" "reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist" "2" - echo "[ RUN ] Selecting mirrors" - sudo pacman -S reflector --noconfirm >/dev/null - sudo reflector --verbose -l 6 --sort rate --save /etc/pacman.d/mirrorlist >/dev/null - echo "[ OK ] Selecting mirrors" #Delete programs (For not updating it) sudo pacman -R clonezilla darkhttpd diffutils grml-zsh-config irssi linux-atm lvm2 man-db man-pages mc ndisc6 nmap smartmontools testdisk vi vim vim-runtime openconnect pcsclite python2 python reflector --noconfirm sudo rm -rf /var/cache/pacman/pkg/*