Use of __user variable
-
I am working on a user management strategy for my RetroPieWebConsole.
The plan is to allow the ability to swap RetroArch configs for whatever user is logged in, but I have to overcome the installation hurdles first.
When looking over retropie_packages.sh, I see it uses this code to install for each user:
# if __user is set, try and install for that user, else use SUDO_USER if [[ -n "$__user" ]]; then user="$__user" if ! id -u "$__user" &>/dev/null; then echo "User $__user not exist" exit 1 fi else user="$SUDO_USER" [[ -z "$user" ]] && user="$(id -un)" fi Right now my application hits the SUDO_USER code and for the life of me, I can't figure out how to set the __user variable using my NodeJS app.
I've tried everything, but it seems my export command does not stick when calling one shell script, then another.
So I had an idea on how I can throw a solution into retropie_packages.sh; we can incorporate this getopts command:
while getopts ":p:u:c:" opt; do case $opt in p) package=$OPTARG ;; u) __user=$OPTARG ;; c) command=$OPTARG ;; \?) echo "Invalid option: -$OPTARG" >&2 exit 1 ;; :) echo "Option -$OPTARG requires an argument." >&2 exit 1 ;; esac done if [[ -n "$__user" ]]; then user="$__user" if ! id -u "$__user" &>/dev/null ; then echo "User $__user not exist" exit 1 fi else user="$SUDO_USER" [[ -z "$user" ]] && user="$(id -un)" fi if [[ -z "$package" ]]; then package="$1" fi if [[ -z "$c" ]]; then command="$2" fi echo "package: $package" echo "user: $user" echo "command: $command" That will allow both support for arg input like -p <package> -u <user> -c <command> and still supports the existing inputs. EX:
pi@gameberry:~/ $ ./testOpts.sh retroarch install_bin package: retroarch user: pi command: install_bin pi@gameberry:~/ $ ./testOpts.sh -p retroarch -c install_bin -u gamer package: retroarch user: gamer command: install_bin
Any thoughts on this? I would like to get opinions or other options before I make a pull request.
-
I don't think the RetroPie setup script supports multiple users. As long as your NodeJS app runs as the user for which RetroPie is installed, you should be fine.
-
We don't - lots of hurdles to support multiple users. I don't want to add additional script parameters btw so no need to do a pr at this time. Thanks.
You can set vars with
sudo __blah= ./retropie_packages.sh
Contributions to the project are always appreciated, so if you would like to support us with a donation you can do so here.
Hosting provided by Mythic-Beasts. See the Hosting Information page for more information.