| 1 | #! /bin/bash |
|---|
| 2 | # |
|---|
| 3 | # confman provides a command-line interface to Rescomp's server configuration |
|---|
| 4 | # management system. |
|---|
| 5 | # |
|---|
| 6 | # confman help |
|---|
| 7 | # Print help and usage information |
|---|
| 8 | # |
|---|
| 9 | # Author: Chris Cowart <ccowart@rescomp.berkeley.edu> |
|---|
| 10 | # Date: 30 March 2006 |
|---|
| 11 | # |
|---|
| 12 | # $Id: confman 1308 2008-01-17 04:14:11Z mattea $ |
|---|
| 13 | |
|---|
| 14 | # Try loading a development library first |
|---|
| 15 | if [ -r ./confmancommon.sh ] ; then |
|---|
| 16 | echo "Loading development library from current working directory." >&2 |
|---|
| 17 | . ./confmancommon.sh |
|---|
| 18 | elif [ -r /usr/local/rescomp/lib/confmancommon.sh ] ; then |
|---|
| 19 | . /usr/local/rescomp/lib/confmancommon.sh |
|---|
| 20 | else |
|---|
| 21 | echo "Can't find confmancommon.sh. Exiting." >&2 |
|---|
| 22 | fi |
|---|
| 23 | |
|---|
| 24 | # Set a default editor |
|---|
| 25 | if [ -z ${EDITOR} ] ; then |
|---|
| 26 | if which vim >/dev/null 2>&1 ; then |
|---|
| 27 | EDITOR="vim" |
|---|
| 28 | else |
|---|
| 29 | EDITOR="vi" |
|---|
| 30 | fi |
|---|
| 31 | fi |
|---|
| 32 | |
|---|
| 33 | # Let's make sure that only you can read your working copy |
|---|
| 34 | # Have to make this less restrictive due to NFS home dirs. |
|---|
| 35 | umask 022 |
|---|
| 36 | |
|---|
| 37 | # This function implements the setup subcommand. It is intended to be called |
|---|
| 38 | # with no arguments, and will error if that's not the case. |
|---|
| 39 | function setup { |
|---|
| 40 | if conf_wcopy_locked? |
|---|
| 41 | then |
|---|
| 42 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 43 | unset WCOPY_LOCK_PID |
|---|
| 44 | else |
|---|
| 45 | if [ -d ${WORK_PATH} ] |
|---|
| 46 | then |
|---|
| 47 | conf_setup_lock |
|---|
| 48 | fi |
|---|
| 49 | local response |
|---|
| 50 | $DEBUG && echo "Running setup" >&4 |
|---|
| 51 | if [ ! -z $* ] ; then |
|---|
| 52 | conf_unlock_wcopy |
|---|
| 53 | print_usage 1 |
|---|
| 54 | elif [ -d ${WORK_PATH} ] ; then |
|---|
| 55 | echo "Looks like ${WORK_PATH} already exists." |
|---|
| 56 | echo "Start over by removing it? (y/N)" |
|---|
| 57 | read response |
|---|
| 58 | if [[ $response =~ '^[yY]([es]|[ES])?' ]] ; then |
|---|
| 59 | rm -rf ${WORK_PATH} |
|---|
| 60 | setup |
|---|
| 61 | else |
|---|
| 62 | echo "Setup failed." >&4 |
|---|
| 63 | conf_unlock_wcopy |
|---|
| 64 | exit 1 |
|---|
| 65 | fi |
|---|
| 66 | else |
|---|
| 67 | mkdir -p ${WORK_PATH} |
|---|
| 68 | conf_setup_lock |
|---|
| 69 | conf_checkout_tree |
|---|
| 70 | conf_unlock_wcopy |
|---|
| 71 | fi |
|---|
| 72 | fi |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | function create { |
|---|
| 76 | if conf_wcopy_locked? |
|---|
| 77 | then |
|---|
| 78 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 79 | unset WCOPY_LOCK_PID |
|---|
| 80 | else |
|---|
| 81 | conf_lock_wcopy |
|---|
| 82 | local module=$1 |
|---|
| 83 | shift |
|---|
| 84 | if [ -z $* ] ; then |
|---|
| 85 | conf_create_module $module |
|---|
| 86 | else |
|---|
| 87 | conf_unlock_wcopy |
|---|
| 88 | print_usage 1 |
|---|
| 89 | fi |
|---|
| 90 | conf_unlock_wcopy |
|---|
| 91 | fi |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | function update { |
|---|
| 95 | if conf_wcopy_locked? |
|---|
| 96 | then |
|---|
| 97 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 98 | unset WCOPY_LOCK_PID |
|---|
| 99 | else |
|---|
| 100 | conf_lock_wcopy |
|---|
| 101 | if [ -z $* ] ; then |
|---|
| 102 | conf_update_tree || conf_cleanExit |
|---|
| 103 | else |
|---|
| 104 | conf_unlock_wcopy |
|---|
| 105 | print_usage 1 |
|---|
| 106 | fi |
|---|
| 107 | conf_unlock_wcopy |
|---|
| 108 | fi |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | function revert { |
|---|
| 112 | if conf_wcopy_locked? |
|---|
| 113 | then |
|---|
| 114 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 115 | unset WCOPY_LOCK_PID |
|---|
| 116 | else |
|---|
| 117 | conf_lock_wcopy |
|---|
| 118 | if [ -z "$*" ] ; then |
|---|
| 119 | conf_unlock_wcopy |
|---|
| 120 | print_usage 1 |
|---|
| 121 | else |
|---|
| 122 | conf_revert $* |
|---|
| 123 | fi |
|---|
| 124 | conf_unlock_wcopy |
|---|
| 125 | fi |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | function commit { |
|---|
| 129 | if conf_system_locked? && conf_wcopy_locked? |
|---|
| 130 | then |
|---|
| 131 | echo "The system is locked by confman[$SYSTEM_LOCK_PID] and your working copy is locked by confman[$WCOPY_LOCK_PID]" >&2 |
|---|
| 132 | unset WCOPY_LOCK_PID |
|---|
| 133 | unset SYSTEM_LOCK_PID |
|---|
| 134 | elif conf_system_locked? |
|---|
| 135 | then |
|---|
| 136 | echo "The system is locked by confman[$SYSTEM_LOCK_PID]." >&2 |
|---|
| 137 | unset SYSTEM_LOCK_PID |
|---|
| 138 | elif conf_wcopy_locked? |
|---|
| 139 | then |
|---|
| 140 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 141 | unset WCOPY_LOCK_PID |
|---|
| 142 | else |
|---|
| 143 | conf_lock_wcopy |
|---|
| 144 | conf_lock_system |
|---|
| 145 | if [ -z $* ] ; then |
|---|
| 146 | local msg=`${mktemp_file}` |
|---|
| 147 | # Moved up per Ian's request. |
|---|
| 148 | echo "Change this file to your log message." > $msg |
|---|
| 149 | echo "BugId: " >> $msg |
|---|
| 150 | ${EDITOR} $msg |
|---|
| 151 | sudo -v |
|---|
| 152 | #Changed this from just update to fix locking issue - arjun |
|---|
| 153 | conf_update_tree || conf_cleanExit |
|---|
| 154 | |
|---|
| 155 | echo "Commit operation started" >&2 |
|---|
| 156 | conf_commit "$LAYERS" $msg || return $? |
|---|
| 157 | for layer in $LAYERS ; do |
|---|
| 158 | echo "Rolling on $layer..." |
|---|
| 159 | conf_rollout $layer || return $? |
|---|
| 160 | done |
|---|
| 161 | for file in $SINGULARITIES ; do |
|---|
| 162 | conf_assemble_sing $file || return $? |
|---|
| 163 | done |
|---|
| 164 | conf_recordAction commit |
|---|
| 165 | conf_markclean |
|---|
| 166 | echo "Commit operation finished successfully" >&2 |
|---|
| 167 | rm -f $msg |
|---|
| 168 | else |
|---|
| 169 | conf_unlock_wcopy |
|---|
| 170 | conf_unlock_system |
|---|
| 171 | print_usage 1 |
|---|
| 172 | fi |
|---|
| 173 | conf_unlock_wcopy |
|---|
| 174 | conf_unlock_system |
|---|
| 175 | fi |
|---|
| 176 | } |
|---|
| 177 | |
|---|
| 178 | # Short name intentional, don't want collision with real install. |
|---|
| 179 | function inst { |
|---|
| 180 | if conf_system_locked? && conf_wcopy_locked? |
|---|
| 181 | then |
|---|
| 182 | echo "The system is locked by confman[$SYSTEM_LOCK_PID] and your working copy is locked by confman[$WCOPY_LOCK_PID]" >&2 |
|---|
| 183 | unset WCOPY_LOCK_PID |
|---|
| 184 | unset SYSTEM_LOCK_PID |
|---|
| 185 | elif conf_system_locked? |
|---|
| 186 | then |
|---|
| 187 | echo "The system is locked by confman[$SYSTEM_LOCK_PID]." >&2 |
|---|
| 188 | unset SYSTEM_LOCK_PID |
|---|
| 189 | elif conf_wcopy_locked? |
|---|
| 190 | then |
|---|
| 191 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 192 | unset WCOPY_LOCK_PID |
|---|
| 193 | else |
|---|
| 194 | conf_lock_wcopy |
|---|
| 195 | conf_lock_system |
|---|
| 196 | local file livefile |
|---|
| 197 | |
|---|
| 198 | if [ -z "$*" ] ; then |
|---|
| 199 | conf_unlock_system |
|---|
| 200 | conf_unlock_wcopy |
|---|
| 201 | print_usage 1 |
|---|
| 202 | else |
|---|
| 203 | local msg=`${mktemp_file}` |
|---|
| 204 | # Moved up per Ian's request. |
|---|
| 205 | echo "Change this file to your log message." > $msg |
|---|
| 206 | echo "BugId: " >> $msg |
|---|
| 207 | ${EDITOR} $msg |
|---|
| 208 | sudo -v |
|---|
| 209 | #changed from update to conf_update_tree to implement locking - arjun |
|---|
| 210 | conf_update_tree || conf_cleanExit |
|---|
| 211 | |
|---|
| 212 | echo "Installation operation started." >&2 |
|---|
| 213 | conf_commit "$LAYERS" $msg || return $? |
|---|
| 214 | for layer in $LAYERS ; do |
|---|
| 215 | conf_install $layer "$@" |
|---|
| 216 | done |
|---|
| 217 | for file in $SINGULARITIES ; do |
|---|
| 218 | conf_assemble_sing $file || conf_cleanExit |
|---|
| 219 | done |
|---|
| 220 | conf_recordAction install |
|---|
| 221 | if ! conf_isclean ; then |
|---|
| 222 | echo "WARNING: Recent 'install' operations prevented a 'sync'" >&2 |
|---|
| 223 | echo "Running a 'commit' is highly recommended." >&2 |
|---|
| 224 | fi |
|---|
| 225 | echo "Installation operation succeeded." >&2 |
|---|
| 226 | conf_unlock_wcopy |
|---|
| 227 | conf_unlock_system |
|---|
| 228 | fi |
|---|
| 229 | fi |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | |
|---|
| 233 | function import { |
|---|
| 234 | if conf_wcopy_locked? |
|---|
| 235 | then |
|---|
| 236 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 237 | unset WCOPY_LOCK_PID |
|---|
| 238 | else |
|---|
| 239 | if conf_lock_wcopy |
|---|
| 240 | then |
|---|
| 241 | local recursive_lock=1 #allows the lock to be deleted after all recursive calls are made |
|---|
| 242 | else |
|---|
| 243 | local recursive_lock=0 #if the lock already exists, this value is set to 0 so that the lock won't be deleted |
|---|
| 244 | fi |
|---|
| 245 | # Check for a force |
|---|
| 246 | local item OPTIND |
|---|
| 247 | force=0 |
|---|
| 248 | while getopts "f" opt ; do |
|---|
| 249 | case $opt in |
|---|
| 250 | f) |
|---|
| 251 | force=1 |
|---|
| 252 | shift |
|---|
| 253 | ;; |
|---|
| 254 | *) |
|---|
| 255 | conf_unlock_wcopy |
|---|
| 256 | print_help 1 |
|---|
| 257 | ;; |
|---|
| 258 | esac |
|---|
| 259 | done |
|---|
| 260 | |
|---|
| 261 | local module=$1 |
|---|
| 262 | local response usefile suffix file layer symlink |
|---|
| 263 | local mode=$DEFAULT_MODE_FILE |
|---|
| 264 | local owner=$DEFAULT_OWNER |
|---|
| 265 | local group=$DEFAULT_GROUP |
|---|
| 266 | local comment=$DEFAULT_COMMENT |
|---|
| 267 | shift |
|---|
| 268 | if [ -z $1 ] ; then |
|---|
| 269 | conf_unlock_wcopy |
|---|
| 270 | print_usage 1 |
|---|
| 271 | fi |
|---|
| 272 | |
|---|
| 273 | sudo -v |
|---|
| 274 | if [ -r $1 ] ; then |
|---|
| 275 | file=`abspath $1` |
|---|
| 276 | else |
|---|
| 277 | # If we can't enter the parent directory, this will help us |
|---|
| 278 | # get the info we need. |
|---|
| 279 | file=`sudo abspath $1` |
|---|
| 280 | fi |
|---|
| 281 | shift |
|---|
| 282 | |
|---|
| 283 | |
|---|
| 284 | # See if we're importing a singularity |
|---|
| 285 | if [[ "$SINGULARITIES" =~ "$file" ]] ; then |
|---|
| 286 | suffix="-$module" |
|---|
| 287 | fi |
|---|
| 288 | |
|---|
| 289 | # Error out when trying to import a symbolic link. |
|---|
| 290 | #if sudo [ -L $file ] ; then |
|---|
| 291 | # echo "$file is a symbolic link!" >&4 |
|---|
| 292 | # conf_cleanExit |
|---|
| 293 | #fi |
|---|
| 294 | |
|---|
| 295 | if [ -f ${WORK_PATH}/${module}${file}${suffix} ] ; then |
|---|
| 296 | echo "$file already exists in your working copy of $module." \ |
|---|
| 297 | "Skipping." >&4 |
|---|
| 298 | import $module $* |
|---|
| 299 | return |
|---|
| 300 | fi |
|---|
| 301 | |
|---|
| 302 | if [ $force = 0 ] ; then |
|---|
| 303 | for layer in $LAYERS ; do |
|---|
| 304 | if [ -f ${WORK_PATH}/${layer}${file}${suffix} ] ; then |
|---|
| 305 | echo "$file already exists in the ${layer}" \ |
|---|
| 306 | "module. Skipping." >&4 |
|---|
| 307 | echo "Did you mean -f ?" >&4 |
|---|
| 308 | import $module $* |
|---|
| 309 | return |
|---|
| 310 | fi |
|---|
| 311 | done |
|---|
| 312 | fi |
|---|
| 313 | |
|---|
| 314 | if sudo [ -L $file ] ; then |
|---|
| 315 | eval `sudo ${stat_cmd} "${stat_opts}" ${file}` |
|---|
| 316 | symlink=`${readlink_cmd} -m $file` |
|---|
| 317 | usefile=`${mktemp_file}` |
|---|
| 318 | echo "# This is a symlink, please do not modify" > $usefile |
|---|
| 319 | |
|---|
| 320 | elif sudo [ -f $file ] ; then |
|---|
| 321 | eval `sudo ${stat_cmd} "${stat_opts}" ${file}` |
|---|
| 322 | # Let's make our best guess on the comment character: |
|---|
| 323 | local tmpfile=`${mktemp_file}` |
|---|
| 324 | local biggestcount=0 |
|---|
| 325 | local count |
|---|
| 326 | |
|---|
| 327 | # Let's see if we can read the file as ourself: |
|---|
| 328 | usefile=`${mktemp_file}` |
|---|
| 329 | if [ ! -r $file ] ; then |
|---|
| 330 | sudo cat $file > $usefile |
|---|
| 331 | else |
|---|
| 332 | cat $file > $usefile |
|---|
| 333 | fi |
|---|
| 334 | |
|---|
| 335 | # Put all non-alphanumerics into a file |
|---|
| 336 | awk '{print $1}' $usefile | egrep -o \ |
|---|
| 337 | "^[^-_A-Za-z0-9]" > $tmpfile |
|---|
| 338 | |
|---|
| 339 | for char in `cat $tmpfile | sort | uniq` ; do |
|---|
| 340 | count=`egrep -o "\\$char" $tmpfile | wc -l` |
|---|
| 341 | if [ $count -gt $biggestcount ] ; then |
|---|
| 342 | biggestcount=$count |
|---|
| 343 | comment="$char" |
|---|
| 344 | fi |
|---|
| 345 | done |
|---|
| 346 | rm $tmpfile |
|---|
| 347 | |
|---|
| 348 | # Convert mode string to base 10: |
|---|
| 349 | mode=`echo "obase=10;ibase=8;$mode" | bc` |
|---|
| 350 | # And use a bitmask to subtract off all write-access |
|---|
| 351 | # 3949d = 7555o |
|---|
| 352 | mode=$(($mode & 3949)) |
|---|
| 353 | # And back to an octet: |
|---|
| 354 | mode=`printf '%04o\n' $mode` |
|---|
| 355 | elif sudo [ -d "$file" ] ; then |
|---|
| 356 | import $module $* ${file}/* |
|---|
| 357 | return |
|---|
| 358 | else |
|---|
| 359 | # Prompt for file owner |
|---|
| 360 | echo "Who should be the file's owner? [ $owner ]" |
|---|
| 361 | read response |
|---|
| 362 | if [ ! -z $response ] ; then |
|---|
| 363 | owner=$response |
|---|
| 364 | fi |
|---|
| 365 | |
|---|
| 366 | # And file's group |
|---|
| 367 | echo "Who should be the file's group? [ $group ]" |
|---|
| 368 | read response |
|---|
| 369 | if [ ! -z $response ] ; then |
|---|
| 370 | group=$response |
|---|
| 371 | fi |
|---|
| 372 | |
|---|
| 373 | # now, the permissions |
|---|
| 374 | echo "What should the file's permissions be? [ $mode ]" |
|---|
| 375 | read response |
|---|
| 376 | if [ ! -z $response ] ; then |
|---|
| 377 | mode=$response |
|---|
| 378 | fi |
|---|
| 379 | |
|---|
| 380 | # now, the comment character |
|---|
| 381 | echo "What string starts comment lines? [ $comment ]" |
|---|
| 382 | read response |
|---|
| 383 | if [ ! -z $response ] ; then |
|---|
| 384 | comment=$response |
|---|
| 385 | fi |
|---|
| 386 | fi |
|---|
| 387 | |
|---|
| 388 | if [ ! -d "${WORK_PATH}/${module}`dirname $file`" ] ; then |
|---|
| 389 | newdir "${WORK_PATH}/${module}`dirname $file`" |
|---|
| 390 | fi |
|---|
| 391 | |
|---|
| 392 | # Time to generate the file |
|---|
| 393 | conf_gen_file $module "${file}${suffix}" $owner $group \ |
|---|
| 394 | $mode "$comment" $usefile "$symlink" |
|---|
| 395 | |
|---|
| 396 | # Removing temporary files |
|---|
| 397 | rm -f $usefile |
|---|
| 398 | |
|---|
| 399 | # Are there more files to import? |
|---|
| 400 | if [ ! -z $1 ] ; then |
|---|
| 401 | import $module $* |
|---|
| 402 | fi |
|---|
| 403 | if [ $recursive_lock = 1 ] |
|---|
| 404 | then |
|---|
| 405 | conf_unlock_wcopy |
|---|
| 406 | fi |
|---|
| 407 | fi |
|---|
| 408 | |
|---|
| 409 | } |
|---|
| 410 | |
|---|
| 411 | function remove { |
|---|
| 412 | if conf_wcopy_locked? |
|---|
| 413 | then |
|---|
| 414 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 415 | unset WCOPY_LOCK_PID |
|---|
| 416 | else |
|---|
| 417 | conf_lock_wcopy |
|---|
| 418 | if [ -z $1 ] |
|---|
| 419 | then |
|---|
| 420 | conf_unlock_wcopy |
|---|
| 421 | print_usage 1 |
|---|
| 422 | fi |
|---|
| 423 | conf_rm_file $* |
|---|
| 424 | conf_unlock_wcopy |
|---|
| 425 | fi |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | function newdir { |
|---|
| 429 | if conf_wcopy_locked? |
|---|
| 430 | then |
|---|
| 431 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 432 | unset WCOPY_LOCK_PID |
|---|
| 433 | else |
|---|
| 434 | conf_lock_wcopy |
|---|
| 435 | local dir=$1 |
|---|
| 436 | local response module realpath |
|---|
| 437 | local mode=$DEFAULT_MODE_DIRECTORY |
|---|
| 438 | local owner=$DEFAULT_OWNER |
|---|
| 439 | local group=$DEFAULT_GROUP |
|---|
| 440 | local comment="dir" |
|---|
| 441 | local workdir=`abspath .` |
|---|
| 442 | if [ -z $1 ] ; then |
|---|
| 443 | conf_unlock_wcopy |
|---|
| 444 | print_usage 1 |
|---|
| 445 | fi |
|---|
| 446 | |
|---|
| 447 | # Find the "real" directory's path if not already specified |
|---|
| 448 | if [[ ! $dir =~ ^/ ]] ; then |
|---|
| 449 | dir="${workdir}/${dir}" |
|---|
| 450 | fi |
|---|
| 451 | module=`echo ${dir#$WORK_PATH} | ${sed_cmd} 's:/([^/]+)/.*:\1:'` |
|---|
| 452 | realpath=${dir#${WORK_PATH}/${module}} |
|---|
| 453 | |
|---|
| 454 | local directories=`echo "$realpath" | sed 's:/: :g'` |
|---|
| 455 | local fulldir="" |
|---|
| 456 | |
|---|
| 457 | for dir_name in $directories; do |
|---|
| 458 | fulldir="${fulldir}/${dir_name}" |
|---|
| 459 | |
|---|
| 460 | # If it exists on the filesystem, get its real attributes |
|---|
| 461 | if [ -d $fulldir ] ; then |
|---|
| 462 | eval `sudo ${stat_cmd} "${stat_opts}" ${fulldir}` |
|---|
| 463 | echo "Making directory $fulldir with ${owner}:${group}, $mode" |
|---|
| 464 | conf_mkdir "$WORK_PATH/$module/$fulldir" $owner $group $mode |
|---|
| 465 | |
|---|
| 466 | # Otherwise, prompt for attributes |
|---|
| 467 | else |
|---|
| 468 | # Prompt for file owner |
|---|
| 469 | echo "Who should be the directory's owner? [ $owner ]" |
|---|
| 470 | read response |
|---|
| 471 | if [ ! -z $response ] ; then |
|---|
| 472 | owner=$response |
|---|
| 473 | fi |
|---|
| 474 | |
|---|
| 475 | # And file's group |
|---|
| 476 | echo "Who should be the directory's group? [ $group ]" |
|---|
| 477 | read response |
|---|
| 478 | if [ ! -z $response ] ; then |
|---|
| 479 | group=$response |
|---|
| 480 | fi |
|---|
| 481 | |
|---|
| 482 | # now, the permissions |
|---|
| 483 | echo "What should the directory's permissions be? [ $mode ]" |
|---|
| 484 | read response |
|---|
| 485 | if [ ! -z $response ] ; then |
|---|
| 486 | mode=$response |
|---|
| 487 | fi |
|---|
| 488 | echo "Making directory $fulldir with ${owner}:${group}, $mode" |
|---|
| 489 | conf_mkdir "$WORK_PATH/$module/$fulldir" $owner $group $mode |
|---|
| 490 | conf_unlock_wcopy |
|---|
| 491 | |
|---|
| 492 | fi |
|---|
| 493 | |
|---|
| 494 | done |
|---|
| 495 | fi |
|---|
| 496 | } |
|---|
| 497 | |
|---|
| 498 | function list { |
|---|
| 499 | local file item |
|---|
| 500 | if [ -z $1 ] ; then |
|---|
| 501 | file=`abspath .` |
|---|
| 502 | else |
|---|
| 503 | file=`abspath $1` |
|---|
| 504 | fi |
|---|
| 505 | echo -e "--------------------------------------------------------" |
|---|
| 506 | echo -e "Mode\tOwner\tGroup\tComment\t\tFilename" |
|---|
| 507 | echo -e "--------------------------------------------------------" |
|---|
| 508 | if [ -f "$file" ] ; then |
|---|
| 509 | conf_list $file |
|---|
| 510 | elif [ -d "$file" ] ; then |
|---|
| 511 | for item in `ls $file` ; do |
|---|
| 512 | conf_list "$file/$item" |
|---|
| 513 | done |
|---|
| 514 | fi |
|---|
| 515 | } |
|---|
| 516 | |
|---|
| 517 | function status { |
|---|
| 518 | conf_status $* |
|---|
| 519 | } |
|---|
| 520 | |
|---|
| 521 | function chowner { |
|---|
| 522 | if conf_wcopy_locked? |
|---|
| 523 | then |
|---|
| 524 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 525 | unset WCOPY_LOCK_PID |
|---|
| 526 | else |
|---|
| 527 | if conf_lock_wcopy |
|---|
| 528 | then |
|---|
| 529 | local recursive_lock=1 #allows the lock to be deleted after all recurisve calls are made |
|---|
| 530 | else |
|---|
| 531 | local recursive_lock=0 #if the lock already exists, this value is set to 0 so that the lock won't be deleted |
|---|
| 532 | fi |
|---|
| 533 | local recursive item OPTIND |
|---|
| 534 | while getopts "R" opt ; do |
|---|
| 535 | case $opt in |
|---|
| 536 | R) |
|---|
| 537 | recursive=1 |
|---|
| 538 | shift |
|---|
| 539 | ;; |
|---|
| 540 | *) |
|---|
| 541 | conf_unlock_wcopy |
|---|
| 542 | print_help 1 |
|---|
| 543 | ;; |
|---|
| 544 | esac |
|---|
| 545 | done |
|---|
| 546 | local owner=$1 |
|---|
| 547 | local file=$2 |
|---|
| 548 | conf_set_prop $file owner $owner |
|---|
| 549 | if [ ! -z $recursive ] && [ -d $file ] ; then |
|---|
| 550 | for item in $file/* ; do |
|---|
| 551 | chowner -R $owner $item |
|---|
| 552 | done |
|---|
| 553 | fi |
|---|
| 554 | if [ $recursive_lock = 1 ] |
|---|
| 555 | then |
|---|
| 556 | conf_unlock_wcopy |
|---|
| 557 | fi |
|---|
| 558 | fi |
|---|
| 559 | } |
|---|
| 560 | |
|---|
| 561 | function chgroup { |
|---|
| 562 | if conf_wcopy_locked? |
|---|
| 563 | then |
|---|
| 564 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 565 | unset WCOPY_LOCK_PID |
|---|
| 566 | else |
|---|
| 567 | if conf_lock_wcopy |
|---|
| 568 | then |
|---|
| 569 | local recursive_lock=1 #allows the lock to be deleted after all recurisve calls are made |
|---|
| 570 | else |
|---|
| 571 | local recursive_lock=0 #if the lock already exists, this value is set to 0 so that the lock won't be deleted |
|---|
| 572 | fi |
|---|
| 573 | local recursive item OPTIND |
|---|
| 574 | while getopts "R" opt ; do |
|---|
| 575 | case $opt in |
|---|
| 576 | R) |
|---|
| 577 | recursive=1 |
|---|
| 578 | shift |
|---|
| 579 | ;; |
|---|
| 580 | *) |
|---|
| 581 | conf_unlock_wcopy |
|---|
| 582 | print_help 1 |
|---|
| 583 | ;; |
|---|
| 584 | esac |
|---|
| 585 | done |
|---|
| 586 | local group=$1 |
|---|
| 587 | local file=$2 |
|---|
| 588 | conf_set_prop $file group $group |
|---|
| 589 | if [ ! -z $recursive ] && [ -d $file ] ; then |
|---|
| 590 | for item in $file/* ; do |
|---|
| 591 | chgroup -R $group $item |
|---|
| 592 | done |
|---|
| 593 | fi |
|---|
| 594 | if [ $recursive_lock = 1 ] |
|---|
| 595 | then |
|---|
| 596 | conf_unlock_wcopy |
|---|
| 597 | fi |
|---|
| 598 | fi |
|---|
| 599 | } |
|---|
| 600 | |
|---|
| 601 | function chmode { |
|---|
| 602 | if conf_wcopy_locked? |
|---|
| 603 | then |
|---|
| 604 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 605 | unset WCOPY_LOCK_PID |
|---|
| 606 | else |
|---|
| 607 | if conf_lock_wcopy |
|---|
| 608 | then |
|---|
| 609 | local recursive_lock=1 #allows the lock to be deleted after all recurisve calls are made |
|---|
| 610 | else |
|---|
| 611 | local recursive_lock=0 #if the lock already exists, this value is set to 0 so that the lock won't be deleted |
|---|
| 612 | fi |
|---|
| 613 | local recursive item OPTIND |
|---|
| 614 | while getopts "R" opt ; do |
|---|
| 615 | case $opt in |
|---|
| 616 | R) |
|---|
| 617 | recursive=1 |
|---|
| 618 | shift |
|---|
| 619 | ;; |
|---|
| 620 | *) |
|---|
| 621 | conf_unlock_wcopy |
|---|
| 622 | print_help 1 |
|---|
| 623 | ;; |
|---|
| 624 | esac |
|---|
| 625 | done |
|---|
| 626 | local mode=$1 |
|---|
| 627 | local file=$2 |
|---|
| 628 | conf_set_prop $file mode $mode |
|---|
| 629 | if [ ! -z $recursive ] && [ -d $file ] ; then |
|---|
| 630 | for item in $file/* ; do |
|---|
| 631 | chmode -R $mode $item |
|---|
| 632 | done |
|---|
| 633 | fi |
|---|
| 634 | if [ $recursive_lock = 1 ] |
|---|
| 635 | then |
|---|
| 636 | conf_unlock_wcopy |
|---|
| 637 | fi |
|---|
| 638 | fi |
|---|
| 639 | } |
|---|
| 640 | |
|---|
| 641 | function chcom { |
|---|
| 642 | if conf_wcopy_locked? |
|---|
| 643 | then |
|---|
| 644 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 645 | unset WCOPY_LOCK_PID |
|---|
| 646 | else |
|---|
| 647 | conf_lock_wcopy |
|---|
| 648 | local comment="$1" |
|---|
| 649 | local file=$2 |
|---|
| 650 | conf_set_prop $file comment "$comment" |
|---|
| 651 | conf_unlock_wcopy |
|---|
| 652 | fi |
|---|
| 653 | } |
|---|
| 654 | |
|---|
| 655 | function chln { |
|---|
| 656 | if conf_wcopy_locked? |
|---|
| 657 | then |
|---|
| 658 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 659 | unset WCOPY_LOCK_PID |
|---|
| 660 | return 1 |
|---|
| 661 | fi |
|---|
| 662 | if [ $# -lt 2 ] ; then |
|---|
| 663 | print_usage 1 |
|---|
| 664 | fi |
|---|
| 665 | |
|---|
| 666 | conf_lock_wcopy |
|---|
| 667 | local symlink="$1" |
|---|
| 668 | local file="$2" |
|---|
| 669 | conf_set_prop "$file" symlink "$symlink" |
|---|
| 670 | conf_unlock_wcopy |
|---|
| 671 | } |
|---|
| 672 | |
|---|
| 673 | function checklook { |
|---|
| 674 | local module=$1 |
|---|
| 675 | local chkdir=${WORK_PATH}/${REPO_CHECKPTS}/${module} |
|---|
| 676 | if [ -z $1 ] ; then |
|---|
| 677 | print_usage 1 |
|---|
| 678 | elif [ -d $chkdir ] ; then |
|---|
| 679 | ls $chkdir |
|---|
| 680 | else |
|---|
| 681 | echo "There are no checkpoints for ${module}." |
|---|
| 682 | fi |
|---|
| 683 | } |
|---|
| 684 | |
|---|
| 685 | function checknew { |
|---|
| 686 | if conf_wcopy_locked? |
|---|
| 687 | then |
|---|
| 688 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 689 | unset WCOPY_LOCK_PID |
|---|
| 690 | else |
|---|
| 691 | conf_lock_wcopy |
|---|
| 692 | local module=$1 |
|---|
| 693 | local checkpoint=$2 |
|---|
| 694 | if [ -z $2 ] ; then |
|---|
| 695 | conf_unlock_wcopy |
|---|
| 696 | print_usage 1 |
|---|
| 697 | else |
|---|
| 698 | conf_new_checkpoint $module $checkpoint |
|---|
| 699 | conf_unlock_wcopy |
|---|
| 700 | fi |
|---|
| 701 | fi |
|---|
| 702 | } |
|---|
| 703 | |
|---|
| 704 | function checkclear { |
|---|
| 705 | if conf_wcopy_locked? |
|---|
| 706 | then |
|---|
| 707 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 708 | unset WCOPY_LOCK_PID |
|---|
| 709 | else |
|---|
| 710 | conf_lock_wcopy |
|---|
| 711 | local module=$1 |
|---|
| 712 | local checkpoint=$2 |
|---|
| 713 | if [ -z $2 ] ; then |
|---|
| 714 | conf_unlock_wcopy |
|---|
| 715 | print_usage 1 |
|---|
| 716 | else |
|---|
| 717 | conf_rm_checkpoint $module $checkpoint |
|---|
| 718 | conf_unlock_wcopy |
|---|
| 719 | fi |
|---|
| 720 | fi |
|---|
| 721 | } |
|---|
| 722 | |
|---|
| 723 | function rollback { |
|---|
| 724 | if conf_system_locked? && conf_wcopy_locked? |
|---|
| 725 | then |
|---|
| 726 | echo "The system is locked by confman[$SYSTEM_LOCK_PID] and your working copy is locked by confman[$WCOPY_LOCK_PID]" >&2 |
|---|
| 727 | unset WCOPY_LOCK_PID |
|---|
| 728 | unset SYSTEM_LOCK_PID |
|---|
| 729 | elif conf_system_locked? |
|---|
| 730 | then |
|---|
| 731 | echo "The system is locked by confman[$SYSTEM_LOCK_PID]." >&2 |
|---|
| 732 | unset SYSTEM_LOCK_PID |
|---|
| 733 | elif conf_wcopy_locked? |
|---|
| 734 | then |
|---|
| 735 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 736 | unset WCOPY_LOCK_PID |
|---|
| 737 | else |
|---|
| 738 | conf_lock_wcopy |
|---|
| 739 | conf_lock_system |
|---|
| 740 | local module=$1 |
|---|
| 741 | local checkpoint=$2 |
|---|
| 742 | local clock=$3 |
|---|
| 743 | if [ -z $2 ] ; then |
|---|
| 744 | conf_unlock_wcopy |
|---|
| 745 | conf_unlock_system |
|---|
| 746 | print_usage 1 |
|---|
| 747 | else |
|---|
| 748 | echo "Rolling $module back to $checkpoint $clock" >&2 |
|---|
| 749 | conf_rollback $module $checkpoint $clock || conf_cleanExit |
|---|
| 750 | for layer in $LAYERS ; do |
|---|
| 751 | echo "Rolling on $layer..." |
|---|
| 752 | conf_rollout $layer || conf_cleanExit |
|---|
| 753 | done |
|---|
| 754 | |
|---|
| 755 | for file in $SINGULARITIES ; do |
|---|
| 756 | conf_assemble_sing $file || conf_cleanExit |
|---|
| 757 | done |
|---|
| 758 | echo "Rollback succeeded." >&2 |
|---|
| 759 | conf_unlock_wcopy |
|---|
| 760 | conf_unlock_system |
|---|
| 761 | fi |
|---|
| 762 | fi |
|---|
| 763 | } |
|---|
| 764 | |
|---|
| 765 | function rmmod { |
|---|
| 766 | if conf_wcopy_locked? |
|---|
| 767 | then |
|---|
| 768 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 769 | unset WCOPY_LOCK_PID |
|---|
| 770 | else |
|---|
| 771 | conf_lock_wcopy |
|---|
| 772 | local module=$1 |
|---|
| 773 | if [ -z $module ] ; then |
|---|
| 774 | conf_unlock_wcopy |
|---|
| 775 | print_usage 1 |
|---|
| 776 | fi |
|---|
| 777 | conf_rmmod $module |
|---|
| 778 | conf_unlock_wcopy |
|---|
| 779 | fi |
|---|
| 780 | } |
|---|
| 781 | |
|---|
| 782 | function rename { |
|---|
| 783 | if conf_wcopy_locked? |
|---|
| 784 | then |
|---|
| 785 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 786 | unset WCOPY_LOCK_PID |
|---|
| 787 | else |
|---|
| 788 | conf_lock_wcopy |
|---|
| 789 | local oldmod=$1 |
|---|
| 790 | local newmod=$2 |
|---|
| 791 | if [ -z $newmod ] ; then |
|---|
| 792 | conf_unlock_wcopy |
|---|
| 793 | print_usage 1 |
|---|
| 794 | fi |
|---|
| 795 | if [ ! -d "${WORK_PATH}/${oldmod}" ] ; then |
|---|
| 796 | echo "${MYNAME}: Error: ${WORK_PATH}/${oldmod} doesn't exist" >&4 |
|---|
| 797 | conf_cleanExit |
|---|
| 798 | fi |
|---|
| 799 | if [ -e "${WORK_PATH}/${newmod}" ] ; then |
|---|
| 800 | echo "${MYNAME}: Error: ${WORK_PATH}/${newmod}: file exists" >&4 |
|---|
| 801 | conf_cleanExit |
|---|
| 802 | fi |
|---|
| 803 | conf_rename $oldmod $newmod |
|---|
| 804 | conf_unlock_wcopy |
|---|
| 805 | fi |
|---|
| 806 | } |
|---|
| 807 | |
|---|
| 808 | function diff { |
|---|
| 809 | conf_diff $* |
|---|
| 810 | } |
|---|
| 811 | |
|---|
| 812 | function log { |
|---|
| 813 | conf_log $* |
|---|
| 814 | } |
|---|
| 815 | |
|---|
| 816 | function copy { |
|---|
| 817 | if conf_wcopy_locked? |
|---|
| 818 | then |
|---|
| 819 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 820 | unset WCOPY_LOCK_PID |
|---|
| 821 | else |
|---|
| 822 | conf_lock_wcopy |
|---|
| 823 | local src=$1 |
|---|
| 824 | local dest=$2 |
|---|
| 825 | if [ -z $2 ] |
|---|
| 826 | then |
|---|
| 827 | conf_unlock_wcopy |
|---|
| 828 | print_usage 1 |
|---|
| 829 | fi |
|---|
| 830 | conf_cp $src $dest |
|---|
| 831 | conf_unlock_wcopy |
|---|
| 832 | fi |
|---|
| 833 | } |
|---|
| 834 | |
|---|
| 835 | function move { |
|---|
| 836 | if conf_wcopy_locked? |
|---|
| 837 | then |
|---|
| 838 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 839 | unset WCOPY_LOCK_PID |
|---|
| 840 | else |
|---|
| 841 | conf_lock_wcopy |
|---|
| 842 | local src=$1 |
|---|
| 843 | local dest=$2 |
|---|
| 844 | if [ -z $2 ] |
|---|
| 845 | then |
|---|
| 846 | conf_unlock_wcopy |
|---|
| 847 | print_usage 1 |
|---|
| 848 | fi |
|---|
| 849 | conf_mv $src $dest |
|---|
| 850 | conf_unlock_wcopy |
|---|
| 851 | fi |
|---|
| 852 | } |
|---|
| 853 | |
|---|
| 854 | function mklink { |
|---|
| 855 | if conf_wcopy_locked? |
|---|
| 856 | then |
|---|
| 857 | echo "Your working copy is locked by confman[$WCOPY_LOCK_PID]." >&2 |
|---|
| 858 | unset WCOPY_LOCK_PID |
|---|
| 859 | return 1 |
|---|
| 860 | fi |
|---|
| 861 | |
|---|
| 862 | if [ $# -lt 2 ] ; then |
|---|
| 863 | print_usage 1 |
|---|
| 864 | fi |
|---|
| 865 | |
|---|
| 866 | local forced |
|---|
| 867 | if [ $1 == "-f" ] ; then |
|---|
| 868 | forced=true |
|---|
| 869 | shift |
|---|
| 870 | if [ $# -lt 2 ] ; then |
|---|
| 871 | print_usage 1 |
|---|
| 872 | fi |
|---|
| 873 | fi |
|---|
| 874 | |
|---|
| 875 | conf_lock_wcopy |
|---|
| 876 | local target=$1 |
|---|
| 877 | local link=$2 |
|---|
| 878 | conf_ln $target $link $forced |
|---|
| 879 | conf_unlock_wcopy |
|---|
| 880 | } |
|---|
| 881 | |
|---|
| 882 | function lsattr { |
|---|
| 883 | if [ -z "$1" ] ; then |
|---|
| 884 | conf_lsattr * |
|---|
| 885 | else |
|---|
| 886 | conf_lsattr "$@" |
|---|
| 887 | fi |
|---|
| 888 | } |
|---|
| 889 | |
|---|
| 890 | function chattr { |
|---|
| 891 | local attr="$1" |
|---|
| 892 | shift |
|---|
| 893 | local value="${1:-true}" |
|---|
| 894 | shift |
|---|
| 895 | if [ -z "$1" ] ; then print_usage 1 ; fi |
|---|
| 896 | |
|---|
| 897 | conf_chattr "$attr" "$value" "$@" |
|---|
| 898 | } |
|---|
| 899 | |
|---|
| 900 | function rmattr { |
|---|
| 901 | local attr="$1" |
|---|
| 902 | shift |
|---|
| 903 | if [ -z "$1" ] ; then print_usage 1 ; fi |
|---|
| 904 | |
|---|
| 905 | conf_rmattr "$attr" "$@" |
|---|
| 906 | } |
|---|
| 907 | |
|---|
| 908 | function state { |
|---|
| 909 | if conf_isclean ; then |
|---|
| 910 | echo "This host is clean." |
|---|
| 911 | else |
|---|
| 912 | echo "This host may be dirty. Consider running a 'commit' operation" |
|---|
| 913 | fi |
|---|
| 914 | } |
|---|
| 915 | |
|---|
| 916 | function audit { |
|---|
| 917 | tarball=$(conf_fetch) |
|---|
| 918 | if ! [ -s $tarball ] |
|---|
| 919 | then |
|---|
| 920 | echo "Could not fetch the tarball." >&2 |
|---|
| 921 | exit 1 |
|---|
| 922 | fi |
|---|
| 923 | |
|---|
| 924 | tmpcopy=$(${mktemp_dir}) |
|---|
| 925 | tmproot=$(${mktemp_dir}) |
|---|
| 926 | |
|---|
| 927 | tar -xzf $tarball -C $tmpcopy |
|---|
| 928 | rm -rf $tarball |
|---|
| 929 | |
|---|
| 930 | for layer in $LAYERS |
|---|
| 931 | do |
|---|
| 932 | local module="${layer}" |
|---|
| 933 | local moduledir="$tmpcopy/$module" |
|---|
| 934 | |
|---|
| 935 | for directory in \ |
|---|
| 936 | `find -L $moduledir -mindepth 1 -type d | grep -v "\.svn"`; do |
|---|
| 937 | local tmpdir=`echo $directory | sed "s:$moduledir::"` |
|---|
| 938 | tmpdir="$tmproot${tmpdir}" |
|---|
| 939 | local owner=`conf_get_prop ${directory} owner` |
|---|
| 940 | local group=`conf_get_prop ${directory} group` |
|---|
| 941 | local mode=`conf_get_prop ${directory} mode` |
|---|
| 942 | local opts="-d -o $owner -g $group -m $mode" |
|---|
| 943 | local cmd="sudo $install_cmd $opts $tmpdir" |
|---|
| 944 | $cmd |
|---|
| 945 | done |
|---|
| 946 | for file in `find -L $moduledir -type f | grep -v "\.svn"` ; do |
|---|
| 947 | local tmpfile=`echo "$file" | sed "s:$moduledir::"` |
|---|
| 948 | local owner=`conf_get_prop ${file} owner` |
|---|
| 949 | local group=`conf_get_prop ${file} group` |
|---|
| 950 | local mode=`conf_get_prop ${file} mode` |
|---|
| 951 | local opts="-o $owner -g $group -m $mode" |
|---|
| 952 | local cmd="sudo $install_cmd $opts $file $tmproot$tmpfile" |
|---|
| 953 | $cmd |
|---|
| 954 | done |
|---|
| 955 | done |
|---|
| 956 | |
|---|
| 957 | for file in $SINGULARITIES |
|---|
| 958 | do |
|---|
| 959 | local livefile="$tmproot${file}" |
|---|
| 960 | local tmpfile=`${mktemp_file}` || exit 1 |
|---|
| 961 | local owner group mode flag livepart msg |
|---|
| 962 | for layer in $LAYERS ; do |
|---|
| 963 | livepart="$tmproot${file}-${layer}" |
|---|
| 964 | myfile="$tmpcopy/${layer}/${file}-${layer}" |
|---|
| 965 | if [ -f $myfile -a -f $livepart ] ; then |
|---|
| 966 | owner=`conf_get_prop ${myfile} owner` |
|---|
| 967 | group=`conf_get_prop ${myfile} group` |
|---|
| 968 | mode=`conf_get_prop ${myfile} mode` |
|---|
| 969 | comment=`conf_get_prop ${myfile} comment` |
|---|
| 970 | cat $livepart >> $tmpfile |
|---|
| 971 | sudo rm $livepart |
|---|
| 972 | flag=1 |
|---|
| 973 | fi |
|---|
| 974 | done |
|---|
| 975 | if [ ! -z $flag ] ; then |
|---|
| 976 | local opts="-o $owner -g $group -m $mode" |
|---|
| 977 | local cmd="sudo $install_cmd $opts $tmpfile $livefile" |
|---|
| 978 | $cmd |
|---|
| 979 | fi |
|---|
| 980 | rm -f $tmpfile |
|---|
| 981 | done |
|---|
| 982 | rm -rf $tmpcopy |
|---|
| 983 | sudo /usr/bin/diff -rPu / $tmproot | grep -v "^Only in" |
|---|
| 984 | sudo rm -rf $tmproot |
|---|
| 985 | |
|---|
| 986 | } |
|---|
| 987 | |
|---|
| 988 | function tester { |
|---|
| 989 | local asd="asddsa" |
|---|
| 990 | local output=`echo $asd | grep -v "qw"` |
|---|
| 991 | echo $output |
|---|
| 992 | } |
|---|
| 993 | |
|---|
| 994 | # Debug mode? |
|---|
| 995 | while getopts "d" opt ; do |
|---|
| 996 | case $opt in |
|---|
| 997 | d) |
|---|
| 998 | DEBUG="true" |
|---|
| 999 | shift |
|---|
| 1000 | ;; |
|---|
| 1001 | *) |
|---|
| 1002 | print_help 1 |
|---|
| 1003 | ;; |
|---|
| 1004 | esac |
|---|
| 1005 | done |
|---|
| 1006 | |
|---|
| 1007 | |
|---|
| 1008 | # Dispatch the subcommand. This must happen last and in the global context. |
|---|
| 1009 | subcommand=$1 |
|---|
| 1010 | shift |
|---|
| 1011 | case $subcommand in |
|---|
| 1012 | help ) print_help "$@" ; exit 0 ;; |
|---|
| 1013 | setup|se* ) setup "$@" ;; |
|---|
| 1014 | status ) status "$@" ;; |
|---|
| 1015 | state ) state ;; |
|---|
| 1016 | create|cr* ) create "$@" ;; |
|---|
| 1017 | update|u* ) update "$@" ;; |
|---|
| 1018 | commit|com* ) commit "$@" ;; |
|---|
| 1019 | import|im* ) import "$@" ;; |
|---|
| 1020 | install|in* ) inst "$@" ;; |
|---|
| 1021 | remove|rem*|rm ) remove "$@" ;; |
|---|
| 1022 | rev* ) revert "$@" ;; |
|---|
| 1023 | ren* ) rename "$@" ;; |
|---|
| 1024 | rmmod ) rmmod "$@" ;; |
|---|
| 1025 | mkdir|mkd* ) newdir "$@" ;; |
|---|
| 1026 | list|ls ) list "$@" ;; |
|---|
| 1027 | link|ln ) mklink "$@" ;; |
|---|
| 1028 | lsattr ) lsattr "$@" ;; |
|---|
| 1029 | chattr ) chattr "$@" ;; |
|---|
| 1030 | rmattr ) rmattr "$@" ;; |
|---|
| 1031 | move|mv ) move "$@" ;; |
|---|
| 1032 | copy|cp ) copy "$@" ;; |
|---|
| 1033 | diff ) diff "$@" ;; |
|---|
| 1034 | log ) log "$@" ;; |
|---|
| 1035 | chmod ) chmode "$@" ;; |
|---|
| 1036 | chown ) chowner "$@" ;; |
|---|
| 1037 | chcom ) chcom "$@" ;; |
|---|
| 1038 | chgrp ) chgroup "$@" ;; |
|---|
| 1039 | chln ) chln "$@" ;; |
|---|
| 1040 | checklook|checklist|chls|chlk ) checklook "$@" ;; |
|---|
| 1041 | checknew|chnw ) checknew "$@" ;; |
|---|
| 1042 | checkclear|chcl|chrm ) checkclear "$@" ;; |
|---|
| 1043 | rollback|ro* ) rollback "$@" ;; |
|---|
| 1044 | audit ) audit "$@" ;; |
|---|
| 1045 | tester ) tester "$@" ;; |
|---|
| 1046 | * ) print_usage 1 ;; |
|---|
| 1047 | esac |
|---|
| 1048 | |
|---|
| 1049 | exit |
|---|
| 1050 | |
|---|
| 1051 | # vim:ts=4 |
|---|
| 1052 | |
|---|