-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchowner
More file actions
executable file
·24 lines (24 loc) · 833 Bytes
/
chowner
File metadata and controls
executable file
·24 lines (24 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
# vi:et lbr noet sw=2 ts=2 tw=79 wrap
# SPDX-FileCopyrightText: 2019-2026 David Rabkin
# SPDX-License-Identifier: 0BSD
#
# Sets the owner from the first argument and sets proper permissions for files
# and directories under the second argument.
#
# shellcheck disable=SC1091,SC2034 # File not following, appears unused.
readonly BASE_APP_VERSION=0.9.20260402
. base.sh
[ "$#" -eq 2 ] || die Wrong arguments, try chowner user directory.
beroot
readonly \
DIR="$2" \
USR="$1"
user_exists "$USR" || die "$USR": No such user.
file_exists "$DIR" || die "$DIR": No such file or directory.
iswritable "$DIR" || die "$DIR" is not writable.
chown -R "$USR" "$DIR"
find "$DIR" -name .DS_Store -delete
find "$DIR" -type d -exec chmod 755 {} \;
find "$DIR" -type f -exec chmod 644 {} \;
log The owner of "$DIR" is changed to "$USR".