Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 58880b617f83fd2bd940d456d40b872a2bf1f692 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/sh
INITIALDIR=`pwd`

# Run script with a different user
case x$1 in x-u__)
    USERID=$2
    shift 2
    sudo -H -u $USERID /bin/sh $0 $@
    exitcode=$?
    if [ $exitcode -ne 0 ]; then
        echo -e "The remote launch failed. Possible reasons:\n  -\"sudo\" is missing on the target.\n  - The user \"$USERID\" does not exist on the target."
    fi
    rm -f "$0"
    exit $exitcode
    ;;
esac

# Commands
{0}

# Launch app
{1}

# Self-destruction
cd "$INITIALDIR" && rm -f "$0" 2>/dev/null
exit 0

Back to the top