1#!/bin/sh 2# Install a freedt service directory. 3 4die () { 5 echo >&2 $1 6 exit 21 7} 8_mkdir () { 9 mkdir $1 || die "Unable to make directory $1" 10} 11_chmod () { 12 chmod $1 $2 || die "Unable to change mode of $2 to $1" 13} 14_chowngrp () { 15 chown $1 $3 || die "Unable to set owner of $3 to $1" 16 chgrp $2 $3 || die "Unable to set group of $3 to $1" 17} 18_cd () { 19 cd $1 || die "Unable to change to $1" 20} 21_touch () { 22 touch $1 || die "Unable to touch $1" 23} 24 25if [ $# -lt 3 ] ; then 26 echo Usage: mkservice account logaccount servicedir 27 echo e.g. mkservice root kernellog /etc/linuxkmsgd 28 exit 20 29fi 30 31user=$1 32grp=`id -g $user` || die "Unable to get group of $user" 33loguser=$2 34loggrp=`id -g $loguser` || die "Unable to get group of $loguser" 35dir=$3 36 37_mkdir $dir 38_chmod 03700 $dir 39_cd $dir 40_mkdir log 41_chmod 02755 log 42_mkdir log/main 43_chowngrp $loguser $loggrp log/main 44_chmod 02755 log/main 45# These are necessary for multilog, but dumblog doesn't need them. 46# _touch log/main/status 47# _chowngrp $loguser $loggrp log/main/status 48# _chmod 0644 log/main/status 49_touch run 50_chmod 0644 run 51cat >run <<EOF 52#!/bin/sh 53exec 2>&1 54exec setuidgid $user #some command# 55EOF 56_chmod 0755 run 57_touch log/run 58_chmod 0644 log/run 59cat >log/run <<EOF 60#!/bin/sh 61exec setuidgid $loguser dumblog main/log 62EOF 63_chmod 0755 log/run 64 65