autoinst

scripts to make automated installations of debian easy
git clone git://deadbeef.fr/autoinst.git
Log | Files | Refs | README | LICENSE

common (1119B)


      1 #!/bin/sh
      2 
      3 badconf()
      4 {
      5 	##beware the sharing!
      6 	##also, in current state, the down file would be kept through
      7 	##reboot, while problems might disappear on new boot!
      8 	#echo $@ | tee ./down
      9 	echo $@
     10 	sv stop $SVNAME
     11 	exit 1
     12 }
     13 
     14 make_dir()
     15 {
     16 	UPDIR="${1:?"UPDIR not provided"}"
     17 	DIR="${2:?"DIR not provided"}"
     18 	USER="${3:-"$SVNAME"}"
     19 	GROUP="${4:-"$SVNAME"}"
     20 
     21 	test -d "/$UPDIR" || badconf "$UPDIR is not a directory"
     22 
     23 	if test ! -d "/$UPDIR/$DIR"
     24 	then
     25 		install -d -m 0750 -o ${USER:-root} -g ${GROUP:-adm} "/$UPDIR/$DIR"
     26 	fi
     27 }
     28 
     29 iptables()
     30 {
     31 	RULES_FILE="${1:?"RULES_FILE not provided"}"
     32 	case $0 in
     33 		"./finish")
     34 			ACTION=-A
     35 			;;
     36 		"./run")
     37 			ACTION=-D
     38 			;;
     39 		*)
     40 			echo "Should only be called by ./run or ./finish scripts"
     41 			exit
     42 			;;
     43 	esac
     44 	while read $LINE
     45 	do
     46 		iptables $ACTION $LINE
     47 	done
     48 }
     49 
     50 set -e
     51 exec 2>&1
     52 exec <&-
     53 
     54 # not using cut because ps prints a header, and option to
     55 # avoid that "feature" is not standard. Other alternative
     56 # would be to not print 1st line, but it would require 2
     57 # pipes (ps | tail | cut) and would be similarly random.
     58 SVNAME="$(ps -oargs $PPID | sed -n '/runsv/ s/runsv // p')"