Skip to content

Instantly share code, notes, and snippets.

@ianliu
Last active May 15, 2025 00:03
Show Gist options
  • Save ianliu/773a6c64cef8488a20a9a6adf12e9c78 to your computer and use it in GitHub Desktop.
Save ianliu/773a6c64cef8488a20a9a6adf12e9c78 to your computer and use it in GitHub Desktop.
#!/bin/bash
run_irpf() {
local prog=$1 dir=$2
echo 'Inside the unshared environment'
echo "Bind mounting $dir -> /home/ian"
mount --bind "$dir" /home/ian/
echo "Running $prog"
su - ian -- /usr/lib/jvm/java-11-openjdk/bin/java -jar "$1"
}
export -f run_irpf
progs=$(find /usr/local/lib/irpf -mindepth 1 -maxdepth 1 -type d -exec basename {} \; |
sort -r | paste -sd \|)
dirs=$(find ~/leao/ -mindepth 1 -maxdepth 1 -type d | paste -sd \|)
zenity --forms \
--add-combo='Programa IRPF' --combo-values="$progs" \
--add-combo='Directory' --combo-values="$dirs" \
--add-entry='Custom directory' | {
if IFS=\| read -r -a ans; then
prog=${ans[0]:+/usr/local/lib/irpf/${ans[0]}/irpf.jar}
dir=${ans[2]:-${ans[1]}}
unshare --user --map-root-user \
unshare --mount --propagation=unchanged \
bash -c "run_irpf \"$prog\" \"$dir\""
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment