#!/bin/sh #------------------------------------------------------------------------------ # /var/install/bin/subversion-tools-permissions - fix file permissions # # Creation : 2018-07-11 daniel # Last Update: 2023-08-26 20:04:41 # # Copyright (c) 2024 the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #------------------------------------------------------------------------------ #include eislib . /var/install/include/eislib repodir="$1" # ---------------------------------------------------------------------------- # set platform settings (has to be centralized somewhere...) # ---------------------------------------------------------------------------- crontab_path=/var/cron/etc/root wwwuser="wwwrun" wwwgroup="nogroup" svngroup="svn" #---------------------------------------------------------------------------- # show wait animation #---------------------------------------------------------------------------- show_wait() { mecho -n " wait [ " colpos=1 while [ -n "$(ps --no-headers $!)" ] do mecho -info -n "." sleep 1 colpos=$((${colpos} + 1)) if [ "${colpos}" -ge 52 ] then mecho " ]" mecho -n " wait [ " colpos=1 fi done mecho " ] " } #---------------------------------------------------------------------------- # copy user permissions to group permissions and honour sticky bit #---------------------------------------------------------------------------- apply_group_permissions() { local files=$(find "$1" -name "*") local file for file in ${files} do local r=$(stat --format="%a" "${file}") if [ "$r" -ge 1000 ] then nr=$((($r / 1000) * 1000 + ($r % 1000) / 100 * 100 \ + ($r % 1000) / 100 * 10 + $r % 10)) else nr=$(($r / 100 * 100 + $r / 100 * 10 + $r % 10)) fi chmod "${nr}" ${file} done } #---------------------------------------------------------------------------- # do the main job #---------------------------------------------------------------------------- mecho " * Setting up file permissions ..." ( chown -R ${wwwuser}:${svngroup} ${repodir} 2> /dev/null chmod a+rw ${repodir}/db/log.* 2> /dev/null apply_group_permissions ${repodir} ) 2> /dev/null 1> /dev/null & show_wait wait $! # show success result (without better knowing)... mecho --ok exit 0