Advertisement
gluk47

run skype in a virtual $HOME

Feb 11th, 2017
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.58 KB | None | 0 0
  1. $ cd ~/bin
  2. $ cat isolate
  3. #!/bin/bash
  4.  
  5. export USER=user ## << set username here
  6. sudo unshare -m -- /home/$USER/bin/.run_unshared.sh "$@"
  7.  
  8. $ cat .run_unshared.sh
  9. #!/bin/bash
  10.  
  11. USER=user ## << set username here
  12.  
  13. nsname="${1////_}"
  14. root="$HOME/.unshared/$nsname"
  15. [[ -d "$root" ]] || {
  16.     mkdir -p "$root" || {
  17.         echo Cannot create the isolated directory "$root"
  18.         exit 1
  19.     }
  20.     chown "$USER:" "$root"
  21. }
  22.  
  23. mount -o bind "$root" $HOME
  24. cd $HOME
  25. sudo -u "$USER" -- "$@"
  26.  
  27. # usage:
  28. # ~/bin/isolate skype
  29. # the skype will see ~/.unshared/skype as its $HOME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement