You are not logged in.

#1 2022-05-19 01:45:14

TheWingedHussar
Member
Registered: 2022-05-19
Posts: 8

[SOLVED] Help with executing scripts in a mount using arch-chroot

I'm attempting to install arch using a bash script.
Problem is, when i run:

"arch-chroot /mnt $HOME/HussarInstaller/scripts/sysconf.sh",

or any script with arch-chroot, it returns:

"chroot: failed to run command ‘/root/HussarInstaller/scripts/sysconf.sh’: Permission denied".

I've consulted the wiki and followed its instruction remount with the execute permission, so i ran the following but retried to no avail:

"mount -o remount,exec /mnt"

Further searching online showed up nothing.

Wiki Page im refrencing:
https://wiki.archlinux.org/title/Chroot#Using_chroot

Full Script:
https://github.com/ThePolishHussar/HussarInstaller

Thanks in advance for any help!

Last edited by TheWingedHussar (2022-05-19 18:01:12)

Offline

#2 2022-05-19 02:01:16

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

What does `ls -l /mnt/root/HussarInstaller/scripts/` give you?

Last edited by Scimmia (2022-05-19 02:21:44)

Offline

#3 2022-05-19 02:09:09

SweepingBishops
Member
Registered: 2022-02-14
Posts: 30

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

Just do something like

cp sysconf.sh /mnt
arch-chroot /mnt
./sysconf.sh

Just remember that the script will be run as root, so $HOME will be mapped to /root.
The first line of the script (the sourcing part) will not work unless you copy that to /mnt/root/HussarInstaller/install.conf
I'd also strongly recommend bringing this up with the author of the script on github.

Offline

#4 2022-05-19 02:16:37

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

They *are* the author, and sourcing other files is not an issue. If they were trying to use someone else's script, that would be off topic here.

Last edited by Scimmia (2022-05-19 02:16:53)

Offline

#5 2022-05-19 02:21:58

TheWingedHussar
Member
Registered: 2022-05-19
Posts: 8

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

"What does `ls -a /mnt/root/HussarInstaller/scripts/` give you?":

at the time the scripts are refrenced:
customize.sh  install.sh  packages.sh  partions.sh  sysconf.sh  system_services.sh

"cp sysconf.sh /mnt
arch-chroot /mnt
./sysconf.sh"

arch-chroot will just chroot and ask for manual input, wont work


"Just remember that the script will be run as root, so $HOME will be mapped to /root.
The first line of the script (the sourcing part) will not work unless you copy that to /mnt/root/HussarInstaller/install.conf
I'd also strongly recommend bringing this up with the author of the script on github."

Ive taken this into account, any scripts run using arch-chroot sources the config file using:
"source $HOME/HussarInstaller/install.conf"

Offline

#6 2022-05-19 02:22:52

Scimmia
Fellow
Registered: 2012-09-01
Posts: 13,729

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

My apologies, I realized I typoed and corrected it as you were replying. I as actually looking for ls -l, not ls -a.

Offline

#7 2022-05-19 02:34:37

SweepingBishops
Member
Registered: 2022-02-14
Posts: 30

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

Scimmia wrote:

They *are* the author

Oh. I also didn't notice that they copied the whole folder into the chroot. My bad

Offline

#8 2022-05-19 02:50:56

TheWingedHussar
Member
Registered: 2022-05-19
Posts: 8

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

"My apologies, I realized I typoed and corrected it as you were replying. I as actually looking for ls -l, not ls -a."

Source (normal root):
-rwxrwxrwx 1 root root  160 May 18 21:06 customize.sh
-rwxrwxrwx 1 root root  417 May 18 21:06 install.sh
-rwxrwxrwx 1 root root 1136 May 18 21:06 packages.sh
-rwxrwxrwx 1 root root 1222 May 18 21:06 partions.sh
-rwxrwxrwx 1 root root 1614 May 18 21:06 sysconf.sh
-rwxrwxrwx 1 root root  302 May 18 21:06 system_services.sh

Coppied (/mnt/root/):
-rw-r--r-- 1 root root  160 May 18 22:11 customize.sh
-rw-r--r-- 1 root root  417 May 18 22:11 install.sh
-rw-r--r-- 1 root root 1136 May 18 22:11 packages.sh
-rw-r--r-- 1 root root 1222 May 18 22:11 partions.sh
-rw-r--r-- 1 root root 1614 May 18 22:11 sysconf.sh
-rw-r--r-- 1 root root  302 May 18 22:11 system_services.sh

I assume i need to add some flag to the cp command to keep these permissions in the copy. Which would that be?

Offline

#9 2022-05-19 03:21:30

SweepingBishops
Member
Registered: 2022-02-14
Posts: 30

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

Try --preserve=mode.
If that does not work for you try the install command with the -m flag instead of cp (look into the man page to see how install works).

Offline

#10 2022-05-19 06:14:38

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

Please use code tags, https://bbs.archlinux.org/help.php#bbcode
Then try

arch-chroot /mnt /bin/sh -c 'echo snafu'

Offline

#11 2022-05-19 18:00:53

TheWingedHussar
Member
Registered: 2022-05-19
Posts: 8

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

SweepingBishops wrote:

Try --preserve=mode.

Didn't work.

SweepingBishops wrote:

If that does not work for you try the install command with the -m flag instead of cp (look into the man page to see how install works).

seth wrote:

Then try
arch-chroot /mnt /bin/sh -c 'echo snafu

Didn't try either, opted to use

chmod a+rwx /mnt/root/HussarInstaller/scripts*

Offline

#12 2022-05-19 18:05:14

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

So you simply lacked permissions on the scripts directory?

Offline

#13 2022-05-19 19:27:26

TheWingedHussar
Member
Registered: 2022-05-19
Posts: 8

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

seth wrote:

So you simply lacked permissions on the scripts directory?

after i coppied them into the mounted system that was the case.

Offline

#14 2022-05-19 19:30:17

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,654

Re: [SOLVED] Help with executing scripts in a mount using arch-chroot

"cp -a" will preserve attributes
Is this the original situation or an effort to solve it following post #3 ?

Offline

Board footer

Powered by FluxBB