Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions www/bin/repomanager
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,25 @@ function permissions

echo "["$(date +"%a %b %-d %H:%M:%S")"][INF] Setting permissions... "

setUID=$(grep www-data /etc/passwd | awk -F ':' '{print $3}')
setGID=$(grep www-data /etc/passwd | awk -F ':' '{print $4}')

# Make sure owner and group and permissions are correct on parent directories
chown www-data:www-data "$WWW_DIR" "$DATA_DIR" "$REPOS_DIR"
chmod 770 "$WWW_DIR" "$DATA_DIR" "$REPOS_DIR"

# Now go deeper and set permissions recursively
chown -R www-data:www-data "$WWW_DIR" > /dev/null 2>&1
chown -R www-data:www-data "$DATA_DIR" > /dev/null 2>&1
# First check, than set
for DIR in ${WWW_DIR} ${DATA_DIR}; do
if [ "$(find ${DIR} \( ! -uid ${setUID} -o ! -gid ${setGID} \) | wc -l)" -gt "0" ]; then
chown -R ${setUID}:${setGID} "$DIR" > /dev/null 2>&1
fi
done
# For repositories, run in background to avoid long wait
chown -R www-data:www-data "$REPOS_DIR" > /dev/null 2>&1 &
# First check, than set
(if [ "$(find ${REPOS_DIR} \( ! -uid ${setUID} -o ! -gid ${setGID} \) | wc -l)" -gt "0" ]; then
chown -R ${setUID}:${setGID} "$REPOS_DIR" > /dev/null 2>&1
fi) &

# Permissions on /.gnupg directory
if [ -d "$GPGHOME" ];then
Expand Down Expand Up @@ -120,4 +130,4 @@ fi

help

exit
exit
Loading