You are not logged in.

#1 2015-10-24 02:37:20

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

[solved] a simple installation script not working

i am writing a very simple arch linux installation script
i am already very familer with how a regular installation works and all i want to do
is automate it so i can get it installed faster

here is the script:

#!/bin/bash

# partitioning and swap
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2

# mount the partitions
mount /dev/sda1 /mnt

# install 
pacstrap /mnt base

# generate fstab
genfstab -p -U /mnt >> /mnt/etc/fstab

# change root
arch-chroot /mnt

# set hostname
echo VirtualBox > /etc/hostname

# set timezone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

# generate locale
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen
echo "en_US ISO-8859-1" >> /etc/locale.gen
locale-gen

# create user
useradd -m -G wheel -s /bin/bash arch

# install base-devel
pacman -S --noconfirm base-devel

# install command line and ncurses programs
pacman -S --noconfirm vim vim-runtime
pacman -S --noconfirm mc
pacman -S --noconfirm sudo 
pacman -S --noconfirm htop

# install xorg
pacman -S --noconfirm mesa
pacman -S --noconfirm xorg
pacman -S --noconfirm xorg-xinit

# install window manager
pacman -S --noconfirm awesome
pacman -S --noconfirm vicious

# install terminal emulators
pacman -S --noconfirm terminator
pacman -S --noconfirm xterm

# install graphical programs
pacman -S --noconfirm firefox
pacman -S --noconfirm pcmanfm

# install grub
pacman -S --noconfirm grub

# configure xinit
echo "exec awesome" > /home/arch/.xinitrc

# configure sudo 
sed -i 's/# %wheel ALL=(ALL) ALL/%wheel ALL=(ALL) ALL/' /etc/sudoers

# configure grub
grub-install --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

# let user know that the install finished
echo "Install Finished"

it assumes i have already partitioned the disks
and will manually handle setting passwords

my only problem is that it stops after running pacstrap
i am new to bash scripting so can anyone please help me

Last edited by blutechgirl (2015-10-24 20:39:14)

Offline

#2 2015-10-24 02:41:23

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [solved] a simple installation script not working

I suspect it actually stops after running genfstab which would be expected.

What do you think arch-chroot actually does?  It launches a new interactive shell in the new root.  So everything after that in the script would not be expected to run.  And even if it did run, it would run in the live iso not in the newly installed system.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#3 2015-10-24 02:46:08

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

is there a way to fix this?

Offline

#4 2015-10-24 02:55:09

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

ok so if it stops after running genfstab then what is it that makes it stop

Offline

#5 2015-10-24 03:00:34

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [solved] a simple installation script not working

It isn't actually stopping. The stuff after "arch-chroot /mnt" won't run in the chroot environment but until after the chroot closes in the host environment. What you want to do is have those commands called inside the chroot environment. The most straightforward way is to have a second script run those commands. It can either be copied by the first script or created by the first script.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#6 2015-10-24 03:04:59

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

ok how will the second script be called though. the aim is for no user intervention other that before and after the installation

Offline

#7 2015-10-24 03:18:16

fsckd
Forum Fellow
Registered: 2009-06-15
Posts: 4,173

Re: [solved] a simple installation script not working

Through the arch-chroot command. Say you created the second script in /mnt/root/install-part2.sh. Then (I think) you would run arch-chroot /mnt /root/install-part2.sh. That should run the second script instead of opening a shell.


aur S & M :: forum rules :: Community Ethos
Resources for Women, POC, LGBT*, and allies

Offline

#8 2015-10-24 03:23:03

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

thanks i will try it

Offline

#9 2015-10-24 13:10:24

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

i tried this and it say no such file or directory
i doubled checked where the second file was
so thats not the problem

Offline

#10 2015-10-24 13:13:11

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [solved] a simple installation script not working

arch-chroot -h
usage: arch-chroot chroot-dir [command]

    -h             Print this help message

If 'command' is unspecified, arch-chroot will launch /bin/sh.

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#11 2015-10-24 19:21:55

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

i did

arch-chroot /mnt ./Archchroot.bash

the second script is in the same directory as the first one
it still says no file or directory
is there another way to call the script inside the chroot with out manual intervention

Offline

#12 2015-10-24 19:42:35

Banton
Member
Registered: 2010-05-28
Posts: 67

Re: [solved] a simple installation script not working

The script has to be inside your chroot, so copy it to /mnt before launching it.

Last edited by Banton (2015-10-24 19:42:44)

Offline

#13 2015-10-24 19:51:12

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

i copied it to the root directory of the new install
and ran

arch-chroot /mnt ./Archchroot.bash

it works
now i just need to see how it works in the script

Offline

#14 2015-10-24 20:19:34

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,532
Website

Re: [solved] a simple installation script not working

Other attempts at this have used a here-document to keep the entire script in one deployable file:

#!/bin/bash

# stuff here to do outside the chroot: partitioning to genfstab
# ...
# ...

cat <<EOF > /mnt/root/part2.sh
# stuff here to do inside the chroot
# ...
# ...
exit # to leave the chroot
EOF

arch-chroot /mnt /root/part2.sh

# Stuff here to do after exiting the chroot ... reboot perhaps.
# ...

"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#15 2015-10-24 20:38:50

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

i copied the second script to /mnt first
and then ran the chroot command
i implemented it in the script and it worked

Offline

#16 2015-10-24 20:41:30

blutechgirl
Member
Registered: 2015-05-27
Posts: 43

Re: [solved] a simple installation script not working

here is what the script looks like now

#!/bin/bash

# partitioning and swap
mkfs.ext4 /dev/sda1
mkswap /dev/sda2
swapon /dev/sda2

# mount the partitions
mount /dev/sda1 /mnt

# install
pacstrap /mnt base

# copy the second script
cp Archchroot.bash /mnt/Archchroot.bash

# generate fstab
genfstab -p -U /mnt >> /mnt/etc/fstab

# change root
arch-chroot /mnt ./Archchroot.bash

anything after that is in the second script

Offline

Board footer

Powered by FluxBB