shithub: 9bbs

ref: b1387b2b58854f371d10d6dbcd85ac6eba802a76
dir: /bin/mkperms/

View raw version
#!/bin/rc
# fix file permissions for etc/ and rooms/ when running as user other than none.
# run from 9bbs install directory.
rfork e
argv0=$0
fn usage {
	echo usage: $argv0 '[ -g group ] [ -m mode]' >[1=2]
	exit usage
}
ngroup=()
nmode=()
if(~ $#* 0)
	usage
while(~ $1 -*){
	switch($1){
	case -g
		ngroup=$2
		shift
	case -m
		nmode=$2
		shift
	case *
		usage
	}
	shift
}
if(! ~ $#* 0)
	usage
if(! grep -s -e ':'^$ngroup^':' /adm/users){
	echo group does not exist.
	exit nogroup
}
for(i in `{walk etc/users}){
	chgrp $ngroup $i
	chmod $nmode $i
	chmod g-w etc
}
for(i in `{walk etc/rooms rooms}){
	chgrp $ngroup $i
	chmod 775 $i
	chmod g-w rooms
}