Changeset 33
- Timestamp:
- 03/28/2006 21:12:09 (6 years ago)
- Location:
- confman
- Files:
-
- 2 edited
-
confman (modified) (9 diffs)
-
confman.conf (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
confman/confman
r32 r33 28 28 else 29 29 echo "Error: Couldn't source the confman shell library" >&2 30 exit 1 31 fi 32 33 # And we read in the layers that make this host 34 if [ -f $RECIPE_PATH ] ; then 35 LAYERS=`cat $RECIPE_PATH` 36 else 37 echo "Error: Couldn't read the host's recipe!" >&2 30 38 exit 1 31 39 fi … … 56 64 $MYNAME chgrp module [ file | directory ] group 57 65 $MYNAME chmod module [ file | directory ] mode 66 $MYNAME chcom module [ file | directory ] comment-character 58 67 $MYNAME checklook module 59 68 $MYNAME checknew module name … … 240 249 The chmod subcommand takes a directory and an mode relative to the system 241 250 root and changes ownership. 251 252 EOF 253 ;; 254 chcom ) 255 cat <<EOF 256 $MYNAME provides a command-line interface to Rescomp's server configuration 257 management system. 258 259 Usage: 260 $MYNAME chcom module [ file | directory ] comment-character 261 262 The chcom subcommand takes a file or directory as an argument and changes the 263 comment string associated with it. This will typically only be useful when 264 confman has guessed the comment character of your file incorrectly. 242 265 243 266 EOF … … 379 402 380 403 if [ -f $file ] ; then 381 echo "The file $file exists in your live filesystem." 382 echo "Would you like to use that one? [ Y/n ]" 383 while read response ; do 384 if [ -z $reponse ] ; then usefile=1 ; break ; fi 385 case $response in 386 y|Y|yes ) 387 usefile=1 388 break 389 ;; 390 n|N|no ) 391 unset usefile 392 break 393 ;; 394 * ) 395 echo "Please answer yes or no." 396 continue 397 ;; 398 esac 399 done 404 usefile=1 400 405 fi 401 406 402 407 if [ ! -z $usefile ] ; then 403 408 eval `stat -f "mode=%Mp%Lp owner=%Su group=%Sg" $file` 404 fi 405 406 # Prompt for file owner 407 echo "Who should be the file's owner? [ $owner ]" 408 read response 409 if [ ! -z $response ] ; then 410 owner=$response 411 fi 412 413 # And file's group 414 echo "Who should be the file's group? [ $group ]" 415 read response 416 if [ ! -z $response ] ; then 417 group=$response 418 fi 419 420 # now, the permissions 421 echo "What should the file's permissions be? [ $mode ]" 422 read response 423 if [ ! -z $response ] ; then 424 mode=$response 425 fi 426 427 # now, the permissions 428 echo "What string starts comment lines? [ $comment ]" 429 read response 430 if [ ! -z $response ] ; then 431 comment=$response 409 # Let's make our best guess on the comment character: 410 local tmpfile=`mktemp -t confman` 411 local biggestcount=0 412 local count 413 414 # Put all non-alphanumerics into a file 415 awk '{print $1}' $file | egrep -o "^[^-_A-Za-z0-9]" > $tmpfile 416 for char in `cat $file | sort | uniq` ; do 417 count=`egrep -o "\\$char" $tmpfile | wc -l` 418 if [ $count -gt $biggestcount ] ; then 419 biggestcount=$count 420 comment="$char" 421 fi 422 done 423 rm $tmpfile 424 425 # Convert mode string to base 10: 426 mode=`echo "obase=10;ibase=8;$mode" | bc` 427 # And use a bitmask to subtract off all write-access 428 # 3949d = 7555o 429 mode=$(($mode & 3949)) 430 # And back to an octet: 431 mode=`printf '%04o\n' $mode` 432 else 433 # Prompt for file owner 434 echo "Who should be the file's owner? [ $owner ]" 435 read response 436 if [ ! -z $response ] ; then 437 owner=$response 438 fi 439 440 # And file's group 441 echo "Who should be the file's group? [ $group ]" 442 read response 443 if [ ! -z $response ] ; then 444 group=$response 445 fi 446 447 # now, the permissions 448 echo "What should the file's permissions be? [ $mode ]" 449 read response 450 if [ ! -z $response ] ; then 451 mode=$response 452 fi 453 454 # now, the comment character 455 echo "What string starts comment lines? [ $comment ]" 456 read response 457 if [ ! -z $response ] ; then 458 comment=$response 459 fi 432 460 fi 433 461 … … 472 500 local owner=$DEFAULT_OWNER 473 501 local group=$DEFAULT_GROUP 502 local comment="dir" 474 503 if [ -z $2 ] ; then 475 504 print_usage 1 … … 480 509 echo 481 510 482 # Prompt for file owner 483 echo "Who should be the directory's owner? [ $owner ]" 484 read response 485 if [ ! -z $response ] ; then 486 owner=$response 487 fi 488 489 # And file's group 490 echo "Who should be the directory's group? [ $group ]" 491 read response 492 if [ ! -z $response ] ; then 493 group=$response 494 fi 495 496 # now, the permissions 497 echo "What should the directory's permissions be? [ $mode ]" 498 read response 499 if [ ! -z $response ] ; then 500 mode=$response 511 if [ -d $dir ] ; then 512 eval `stat -f "mode=%Mp%Lp owner=%Su group=%Sg" $dir` 513 514 # Convert mode string to base 10: 515 mode=`echo "obase=10;ibase=8;$mode" | bc` 516 # And use a bitmask to subtract off all write-access 517 # 3949d = 7555o 518 mode=$(($mode & 3949)) 519 # And back to an octet: 520 mode=`printf '%04o\n' $mode` 521 else 522 # Prompt for file owner 523 echo "Who should be the directory's owner? [ $owner ]" 524 read response 525 if [ ! -z $response ] ; then 526 owner=$response 527 fi 528 529 # And file's group 530 echo "Who should be the directory's group? [ $group ]" 531 read response 532 if [ ! -z $response ] ; then 533 group=$response 534 fi 535 536 # now, the permissions 537 echo "What should the directory's permissions be? [ $mode ]" 538 read response 539 if [ ! -z $response ] ; then 540 mode=$response 541 fi 501 542 fi 502 543 503 544 # Time to create the directory. 545 echo "Making $dir in $module with ${owner}:${group}, $mode" 504 546 conf_mkdir $module $dir $owner $group $mode 505 547 } … … 512 554 file=`abspath $1` 513 555 fi 514 echo $file >&2515 556 echo -e "--------------------------------------------------------" 516 557 echo -e "Mode\tOwner\tGroup\tComment\t\tFilename" … … 544 585 local mode=$3 545 586 conf_set_prop $module $file mode $mode 587 } 588 589 function chcom { 590 local module=$1 591 local file=$2 592 local comment="$3" 593 conf_set_prop $module $file comment "$comment" 546 594 } 547 595 … … 669 717 chowner $* 670 718 ;; 719 chcom ) 720 chcom $* 721 ;; 671 722 chgrp ) 672 723 chgroup $* -
confman/confman.conf
r30 r33 31 31 # The path to our current host's recipe file 32 32 # RECIPE_PATH="/usr/local/rescomp/etc/recipe" 33 # RECIPE_PATH="/usr/local/rescomp/etc/recipe" 34 LAYERS="core kermit" 33 RECIPE_PATH="/usr/local/rescomp/etc/recipe" 35 34 36 35 # The list of singularities on this host
Note: See TracChangeset
for help on using the changeset viewer.
