summaryrefslogtreecommitdiffstats
path: root/cron-jobs/adjust-permissions
blob: e0b6e4e53bc28f6d739365b4b232da7a056a1a26 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash

script_lock

. "$(dirname $0)/../db-functions"
. "$(dirname $0)/../config"

get_dir_owner() {
	case $1 in
		core)
			echo "ftp:ftp-arch" ;;
		extra)
			echo "ftp:ftp-extra" ;;
		testing)
			echo "ftp:ftp-extra" ;;
		staging)
			echo "ftp:ftp-extra" ;;
		kde-unstable)
			echo "ftp:ftp-extra" ;;
		gnome-unstable)
			echo "ftp:ftp-extra" ;;
		community)
			echo "root:tusers" ;;
		community-testing)
			echo "root:tusers" ;;
		community-staging)
			echo "root:tusers" ;;
		multilib)
			echo "root:multilib" ;;
		pool/packages)
			echo "ftp:ftp-extra" ;;
		pool/community)
			echo "root:tusers" ;;
	esac
}

#adjust the nice level to run at a lower priority
/usr/bin/renice +10 -p $$ > /dev/null

pushd $FTP_BASE >/dev/null
for d in $(get_repos_for_host); do
	owner="$(get_dir_owner $d)"
	/bin/chown -R $owner $d/os/{any,i686,x86_64}
	/bin/chmod -R g+w $d/os/{any,i686,x86_64}
done
for p in $(get_pkgpool_for_host); do
	owner="$(get_dir_owner $p)"
	/bin/chown $owner $p
	/bin/chmod g+w $p
done
/bin/chmod 555 $FTP_BASE
popd >/dev/null

script_unlock