Changeset 587 for trunk/confman.in
- Timestamp:
- 12/23/2011 15:18:16 (5 months ago)
- File:
-
- 1 edited
-
trunk/confman.in (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/confman.in
r554 r587 654 654 } 655 655 656 function cnf_touch { 657 local file="$1" 658 659 local owner="${DEFAULT_OWNER}" 660 local group="${DEFAULT_GROUP}" 661 local mode="${DEFAULT_MODE_FILE}" 662 local comment="${DEFAULT_COMMENT}" 663 local wcopy_lock 664 local livefile 665 666 if [ -z "${file}" ]; then 667 print_usage 1 668 fi 669 670 wcopy_lock=$(conf_lock_wcopy) 671 672 # Resolve the absolute path to the file 673 file="$("${ABSPATH}" .)/${file}" 674 675 # If the filename doesn't begin with WORK_PATH, we can't operate here 676 if [ "${file#${WORK_PATH}}" = "${file}" ]; then 677 echo "Cannot operate on non-working-copy file: ${file}" >&4 678 fi 679 680 module=${file#${WORK_PATH}/} 681 module=${module%%/*} 682 livefile="/${file#${WORK_PATH}/*/}" 683 684 # If it exists on the live filesystem, pull the attributes from there 685 if [ -f "${livefile}" ]; then 686 eval `$SUDO ${stat_cmd} "${stat_opts}" "${livefile}"` 687 688 # TODO: Guess the comment character too 689 690 # Convert mode string to base 10: 691 mode=`echo "obase=10;ibase=8;${mode}" | bc` 692 # And use a bitmask to subtract off all write-access 693 # 3949d = 7555o 694 mode=$((${mode} & 3949)) 695 # And back to an octet: 696 mode=`printf '%04o\n' ${mode}` 697 698 echo "Touching file ${livefile} with ${owner}:${group}, ${mode}, comment string ${comment}" 699 conf_gen_file "${module}" "${livefile}" "${owner}" "${group}" "${mode}" "${comment}" "" "" 700 701 # Otherwise, prompt for attributes 702 else 703 # Prompt for file owner 704 echo "Who should be the file's owner? [ ${owner} ]" 705 read response 706 if [ -n "${response}" ]; then 707 owner="${response}" 708 fi 709 710 # Prompt for file group 711 echo "Who should be the file's group? [ ${group} ]" 712 read response 713 if [ -n "${response}" ]; then 714 group="${response}" 715 fi 716 717 # Prompt for file mode 718 echo "What should the file's permissions be? [ ${mode} ]" 719 read response 720 if [ -n "${response}" ]; then 721 mode="${response}" 722 fi 723 724 # Prompt for file comment 725 echo "What string starts comment lines? [ ${comment} ]" 726 read response 727 if [ -n "${response}" ]; then 728 comment="${response}" 729 fi 730 731 echo "Touching file ${livefile} with ${owner}:${group}, ${mode}, comment string ${comment}" 732 conf_gen_file "${module}" "${livefile}" "${owner}" "${group}" "${mode}" "${comment}" "" "" 733 fi 734 735 conf_unlock_wcopy "${wcopy_lock}" 736 } 737 656 738 function list { 657 739 local file item … … 1271 1353 rmmod ) rmmod "$@" ;; 1272 1354 mkdir|mkd* ) newdir "$@" ;; 1355 touch ) cnf_touch "$@" ;; 1273 1356 list|ls ) list "$@" ;; 1274 1357 link|ln ) mklink "$@" ;;
Note: See TracChangeset
for help on using the changeset viewer.
