Open rmlamarche opened 3 years ago
As a follow-up thought, executing who am i
instead of whoami
will get the current session user, regardless of sudo/elevation:
Something like this might work if you don't wish to change the behavior too much:
DIR=/home/$(who am i | awk '{print $1}')/files
This still relies on the home directory of the user being in /home/username/files
however. Tilde expansion is probably the way to go if you wish to force this into the user's $HOME/files
directory
I also got this to extract properly (after I had removed pi
and used a different username) by replacing all pi
references with $SUDO_USER
Because of the fact that this script needs to be run with
sudo
and runswhoami
in a few places under the hood, it fails to unzip quectel-CM.zip (becausesudo whoami
returnsroot
, but the default home directory on raspi os is/home/pi
).It seems this recent commit is where this was introduced: https://github.com/sixfab/Sixfab_RPi_3G-4G-LTE_Base_Shield/commit/a669005d480605e2cae75e5d384d0f30f929f331
I would suggest that the
/home/$(whoami)/files/...
bit be removed altogether, and that the script just uses the current working directory (something like./files/
or./quectel-cm-files/
etc.). I'm happy to try to contribute on this, but I don't have a raspi handy for a few days so it will be tricky to test.Here is a sample output:
https://github.com/sixfab/Sixfab_RPi_3G-4G-LTE_Base_Shield/blob/a669005d480605e2cae75e5d384d0f30f929f331/tutorials/QMI_tutorial/qmi_install.sh#L15