Skip to content

Commit

Permalink
Fix permissions when installing system-wide
Browse files Browse the repository at this point in the history
  • Loading branch information
rootmos committed Nov 16, 2023
1 parent 5675eb3 commit 9818547
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
if [ "${{ matrix.kind }}" = "user" ]; then
./install.sh -u
elif [ "${{ matrix.kind }}" = "system" ]; then
sudo ./install.sh -s
SUDO=sudo ./install.sh -s
else
exit 1
fi
Expand Down
17 changes: 10 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ EOF
exit "${1-0}"
}

SUDO=${SUDO-}
DESTDIR=${DESTDIR-$HOME/.local}
DIR_MODE=0700
APP=${APP-displayswitcheroo}
while getopts "dusah-" OPT; do
case $OPT in
d) DESTDIR=$OPTARG ;;
u) DESTDIR=$HOME/.local ;;
s) DESTDIR=/usr ;;
u) DESTDIR=$HOME/.local; DIR_MODE=0700;;
s) DESTDIR=/usr; DIR_MODE=0755 ;;
a) APP=$OPTARG ;;
h) usage ;;
-) break ;;
Expand All @@ -34,9 +36,10 @@ shift $((OPTIND-1))

make -C "$SCRIPT_DIR" clean build EXTRA_CFLAGS="-DXDG_APP='\"$APP\"'"

mkdir -pm 0700 "$DESTDIR/bin"
install -v "$SCRIPT_DIR/src/cli.exe" "$DESTDIR/bin/$APP"

mkdir -pm 0700 "$DESTDIR/share/$APP"
install -v -D "$SCRIPT_DIR/data/displayswitcheroo/list.lua" "$DESTDIR/share/$APP/list.lua"
install -v -D "$SCRIPT_DIR/data/displayswitcheroo/displayswitcheroo.lua" "$DESTDIR/share/$APP/$APP.lua"
$SUDO mkdir -pm "$DIR_MODE" "$DESTDIR/bin"
$SUDO install -v "$SCRIPT_DIR/src/cli.exe" "$DESTDIR/bin/$APP"

$SUDO mkdir -pm "$DIR_MODE" "$DESTDIR/share/$APP"
$SUDO install -v -D "$SCRIPT_DIR/data/displayswitcheroo/list.lua" "$DESTDIR/share/$APP/list.lua"
$SUDO install -v -D "$SCRIPT_DIR/data/displayswitcheroo/displayswitcheroo.lua" "$DESTDIR/share/$APP/$APP.lua"

0 comments on commit 9818547

Please sign in to comment.