shell-things/chmod

52 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

#!/usr/bin/env bash
2023-02-21 18:08:54 +01:00
# This script removes permissions from other people than the owner to
# files/folders that they don't have access to and where they don't need
# access.
set -x
# You don't want to make this verbose.
chmod g-rwx,o-rwx "$HOME" -R
2024-08-15 08:24:38 +02:00
touch $HOME/.oidentd.conf
2024-08-15 08:24:38 +02:00
chmod -v u+rw,g-wx+r,o-wx+r $HOME/.oidentd.conf
2024-08-15 08:24:38 +02:00
touch $HOME/.ICEauthority
chmod -v o-rw+x,g-rw+x $HOME
2024-08-15 08:24:38 +02:00
mkdir -p $HOME/public_html/
chmod -v -R 755 $HOME/public_html/
2024-08-15 08:24:38 +02:00
touch $HOME/.face
touch $HOME/.forward
touch $HOME/.netrc
chmod -v a+r-wx,u+rw $HOME/.face
chmod -v a+r-wx,u+rw $HOME/.forward
chmod -v 600 $HOME/.netrc
2024-08-15 08:24:38 +02:00
mkdir -p $HOME/.ssh
chmod -v 700 $HOME/.ssh
touch $HOME/.ssh/authorized_keys
chmod -v 600 $HOME/.ssh/authorized_keys
2024-08-15 08:22:32 +02:00
mkdir -p "$HOME/AppImages"
chmod a+rx "$HOME/AppImages/" "$HOME/AppImages/*.appimage"
# if we have support for setting ACL, some of this becomes easier (although maybe redundant)
if hash setfacl 2> /dev/null; then
2024-08-15 08:24:38 +02:00
setfacl --modify u:$(id -un):rw,g:$(id -gn):r,o:r $HOME/.oidentd.conf
2024-08-15 08:22:32 +02:00
setfacl --modify=u:$(id -un):rwX,g:$(id -gn):rX,o:rX "$HOME/AppImages/"
2024-08-15 08:24:38 +02:00
setfacl --recursive --modify u:$(id -un):rwX,g:$(id -gn):rX,o:rX $HOME/public_html/
2024-08-15 08:22:32 +02:00
for appimage in $(find $HOME/AppImages/*.appimage); do
setfacl --modify=u:$(id -un):rwX,g:$(id -gn):rX,o:rX $appimage
done
# Enabling laziness pt. …
2024-08-15 08:24:38 +02:00
if [[ -d $HOME/.shell-things ]]; then
setfacl --recursive --modify u:$(id -un):rwX,g:$(id -gn):rX,o:rX $HOME/.shell-things/
fi
fi
2014-10-09 21:12:25 +02:00
set +x