-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathguisu.sh
35 lines (34 loc) · 986 Bytes
/
guisu.sh
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
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
trap 'onCtrlC' INT
function onCtrlC () {
echo "Stopping"
rm $XDG_RUNTIME_DIR/guisu:$PID
rm $XDG_RUNTIME_DIR/guisu-$COMMAND_NAME:$PID
echo "Temfs cleared"
}
PID=$$
COMMAND_NAME=$1
echo PID:" "$PID
if [ -e $XDG_RUNTIME_DIR/guisu:$PID ]
then
echo "Same PID found"
rm $XDG_RUNTIME_DIR/guisu:$PID
fi
echo "Making fifo"
mkfifo $XDG_RUNTIME_DIR/guisu:$PID
echo "Fifo maken"
echo "Making guisu shell of $COMMAND_NAME"
echo '#!/usr/bin/env bash'>$XDG_RUNTIME_DIR/guisu-$1:$PID
echo "pkexec bash -c \"source $XDG_RUNTIME_DIR/guisu:$PID;$*\"">>$XDG_RUNTIME_DIR/guisu-$1:$PID
echo 'exit 0'>>$XDG_RUNTIME_DIR/guisu-$1:$PID
chmod 755 $XDG_RUNTIME_DIR/guisu-$1:$PID
echo "Guisu shell of $COMMAND_NAME maken"
echo "Piping env"
export > $XDG_RUNTIME_DIR/guisu:$PID&
echo "Pkexec running"
pkexec $XDG_RUNTIME_DIR/guisu-$1:$PID
echo "Pkexec run finnished"
rm $XDG_RUNTIME_DIR/guisu:$PID
rm $XDG_RUNTIME_DIR/guisu-$COMMAND_NAME:$PID
echo "Temfs cleared"
exit 0