| 1 | #! /bin/bash |
|---|
| 2 | # |
|---|
| 3 | # This is a confman shell library that provides usage and help information. |
|---|
| 4 | # I wanted to get it out of the main script, cause it's really long. This also |
|---|
| 5 | # makes modularizing the code (think foreign languages if this ever goes |
|---|
| 6 | # public) (Hah!) in the future. |
|---|
| 7 | # |
|---|
| 8 | # Author: Chris Cowart <ccowart@rescomp.berkeley.edu> |
|---|
| 9 | # Date: 14 April 2006 |
|---|
| 10 | # |
|---|
| 11 | # $Id$ |
|---|
| 12 | |
|---|
| 13 | function print_usage { |
|---|
| 14 | cat <<EOF |
|---|
| 15 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 16 | configuration management system. |
|---|
| 17 | |
|---|
| 18 | Usage: |
|---|
| 19 | $MYNAME [ help | -h | --help ] [ command ] |
|---|
| 20 | $MYNAME setup |
|---|
| 21 | $MYNAME update |
|---|
| 22 | $MYNAME commit |
|---|
| 23 | $MYNAME diff [ working_copy ] |
|---|
| 24 | $MYNAME log [ working_copy ] |
|---|
| 25 | $MYNAME create module |
|---|
| 26 | $MYNAME rmmod module |
|---|
| 27 | $MYNAME rename oldmodule newmodule |
|---|
| 28 | $MYNAME import module livefile |
|---|
| 29 | $MYNAME install workingfile [ workingfile ... ] |
|---|
| 30 | $MYNAME status [ working_copy ] |
|---|
| 31 | $MYNAME state |
|---|
| 32 | $MYNAME ls [ workingfile | workingdirectory ] |
|---|
| 33 | $MYNAME lsattr [ workingfile | workingdirectory ] |
|---|
| 34 | $MYNAME chattr attribute value [ workingfile | workingdirectory ] |
|---|
| 35 | $MYNAME rmattr attribute [ workingfile | workingdirectory ] |
|---|
| 36 | $MYNAME rm workingfile |
|---|
| 37 | $MYNAME cp src_working_copy dest_working_copy |
|---|
| 38 | $MYNAME mv src_working_copy dest_working_copy |
|---|
| 39 | $MYNAME mkdir workingdirectory |
|---|
| 40 | $MYNAME revert workingfile |
|---|
| 41 | $MYNAME chown owner [ workingfile | workingdirectory ] |
|---|
| 42 | $MYNAME chgrp group [ workingfile | workingdirectory ] |
|---|
| 43 | $MYNAME chmod mode [ workingfile | workingdirectory ] |
|---|
| 44 | $MYNAME chcom comment-character [ workingfile | workingdirectory ] |
|---|
| 45 | $MYNAME checklook module |
|---|
| 46 | $MYNAME checknew module name |
|---|
| 47 | $MYNAME checkclear module name |
|---|
| 48 | $MYNAME rollback module [ checkpoint | YYYYMMDD [HHMM] ] |
|---|
| 49 | |
|---|
| 50 | For specific information on a particular $MYNAME subcommand, please run |
|---|
| 51 | $MYNAME help subcommand |
|---|
| 52 | |
|---|
| 53 | eg: $MYNAME help rollback |
|---|
| 54 | |
|---|
| 55 | EOF |
|---|
| 56 | |
|---|
| 57 | exit $1 |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | function print_help { |
|---|
| 61 | case $1 in |
|---|
| 62 | se* ) |
|---|
| 63 | cat <<EOF |
|---|
| 64 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 65 | configuration management system. |
|---|
| 66 | |
|---|
| 67 | Usage: |
|---|
| 68 | $MYNAME setup |
|---|
| 69 | |
|---|
| 70 | The setup command is intended to be run the first time you use $MYNAME. |
|---|
| 71 | It will generate your working copy. setup takes no additional arguments. |
|---|
| 72 | |
|---|
| 73 | EOF |
|---|
| 74 | ;; |
|---|
| 75 | cr* ) |
|---|
| 76 | cat <<EOF |
|---|
| 77 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 78 | configuration management system. |
|---|
| 79 | |
|---|
| 80 | Usage: |
|---|
| 81 | $MYNAME create module |
|---|
| 82 | |
|---|
| 83 | The create command will cause a new module, named module, to appear as a |
|---|
| 84 | top-level-directory in your working copy. This change will also be made to |
|---|
| 85 | the repositry at the same time. |
|---|
| 86 | |
|---|
| 87 | EOF |
|---|
| 88 | ;; |
|---|
| 89 | rmm* ) |
|---|
| 90 | cat <<EOF |
|---|
| 91 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 92 | configuration management system. |
|---|
| 93 | |
|---|
| 94 | Usage: |
|---|
| 95 | $MYNAME rmmod module |
|---|
| 96 | This command will delete the specified module from your working copy. Use with |
|---|
| 97 | care. |
|---|
| 98 | EOF |
|---|
| 99 | ;; |
|---|
| 100 | ren* ) |
|---|
| 101 | cat <<EOF |
|---|
| 102 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 103 | configuration management system. |
|---|
| 104 | |
|---|
| 105 | Usage: |
|---|
| 106 | $MYNAME rename oldmodule newmodule |
|---|
| 107 | |
|---|
| 108 | Rename oldmoule to newmodule, updating all singularities, headers, and |
|---|
| 109 | otherwise performing black magic. |
|---|
| 110 | |
|---|
| 111 | EOF |
|---|
| 112 | ;; |
|---|
| 113 | u* ) |
|---|
| 114 | cat <<EOF |
|---|
| 115 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 116 | configuration management system. |
|---|
| 117 | |
|---|
| 118 | Usage: |
|---|
| 119 | $MYNAME update |
|---|
| 120 | |
|---|
| 121 | The update command will update your working copy of all the modules |
|---|
| 122 | appearing in the current host's recipe file. This command does not alter |
|---|
| 123 | the repository. |
|---|
| 124 | |
|---|
| 125 | EOF |
|---|
| 126 | ;; |
|---|
| 127 | d* ) |
|---|
| 128 | cat <<EOF |
|---|
| 129 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 130 | configuration management system. |
|---|
| 131 | |
|---|
| 132 | Usage: |
|---|
| 133 | $MYNAME diff [ working_copy ] |
|---|
| 134 | |
|---|
| 135 | Look at the changes you've made to your working copy of a file or directory. |
|---|
| 136 | EOF |
|---|
| 137 | ;; |
|---|
| 138 | lo* ) |
|---|
| 139 | cat <<EOF |
|---|
| 140 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 141 | configuration management system. |
|---|
| 142 | |
|---|
| 143 | Usage: |
|---|
| 144 | $MYNAME log [ working_copy ] |
|---|
| 145 | |
|---|
| 146 | Look at the log entries for the file or directory specified by working_copy. |
|---|
| 147 | EOF |
|---|
| 148 | ;; |
|---|
| 149 | status ) |
|---|
| 150 | cat <<EOF |
|---|
| 151 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 152 | configuration management system. |
|---|
| 153 | |
|---|
| 154 | Usage: |
|---|
| 155 | $MYNAME status [ working_copy ] |
|---|
| 156 | |
|---|
| 157 | Look at the status entries for the file or directory specified by working_copy. |
|---|
| 158 | EOF |
|---|
| 159 | ;; |
|---|
| 160 | state ) |
|---|
| 161 | cat <<EOF |
|---|
| 162 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 163 | configuration management system. |
|---|
| 164 | |
|---|
| 165 | Usage: |
|---|
| 166 | $MYNAME state |
|---|
| 167 | |
|---|
| 168 | This command indicates whether the system is "dirty" or "clean." |
|---|
| 169 | |
|---|
| 170 | A dirty system is one that has missed an automated "sync" operation in order |
|---|
| 171 | to preserve changes made by installation operations occuring between the |
|---|
| 172 | repository's export and the system's call to "sync." |
|---|
| 173 | |
|---|
| 174 | Dirty systems may have out-of-date configuration files. Subsquent sync or |
|---|
| 175 | commit operations can bring the sytem up-to-date. |
|---|
| 176 | EOF |
|---|
| 177 | ;; |
|---|
| 178 | cp ) |
|---|
| 179 | cat <<EOF |
|---|
| 180 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 181 | configuration management system. |
|---|
| 182 | |
|---|
| 183 | Usage: |
|---|
| 184 | $MYNAME cp src_working_copy dest_working_copy |
|---|
| 185 | |
|---|
| 186 | Copy source to destination. Arguments must be working copies. |
|---|
| 187 | EOF |
|---|
| 188 | ;; |
|---|
| 189 | mv ) |
|---|
| 190 | cat <<EOF |
|---|
| 191 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 192 | configuration management system. |
|---|
| 193 | |
|---|
| 194 | Usage: |
|---|
| 195 | $MYNAME mv src_working_copy dest_working_copy |
|---|
| 196 | |
|---|
| 197 | Move source to destination. Arguments must be working copies. |
|---|
| 198 | EOF |
|---|
| 199 | ;; |
|---|
| 200 | co* ) |
|---|
| 201 | cat <<EOF |
|---|
| 202 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 203 | configuration management system. |
|---|
| 204 | |
|---|
| 205 | Usage: |
|---|
| 206 | $MYNAME commit |
|---|
| 207 | |
|---|
| 208 | The commit command causes your changes to take effect. This means that |
|---|
| 209 | first, your working copy of all of the modules in the current host's |
|---|
| 210 | recipe will be committed to the repository. This happens after we've run |
|---|
| 211 | a $MYNAME update to prevent out-of-date conflicts. If there are any |
|---|
| 212 | conflicts that require human intervention, the command will fail and exit |
|---|
| 213 | non-zero. |
|---|
| 214 | |
|---|
| 215 | Once $MYNAME is satisfied that all of your changes have been propogated to |
|---|
| 216 | the repository, we will roll-out your working copy to the live filesystem. |
|---|
| 217 | Every module appearing in the host's recipe file will be rolled out IN THE |
|---|
| 218 | ORDER OF APPEARANCE. |
|---|
| 219 | |
|---|
| 220 | EOF |
|---|
| 221 | ;; |
|---|
| 222 | im* ) |
|---|
| 223 | cat <<EOF |
|---|
| 224 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 225 | configuration management system. |
|---|
| 226 | |
|---|
| 227 | Usage: |
|---|
| 228 | $MYNAME import module livefile |
|---|
| 229 | |
|---|
| 230 | The import subcommand adds the specified file to your working copy of the |
|---|
| 231 | repository. |
|---|
| 232 | |
|---|
| 233 | EOF |
|---|
| 234 | ;; |
|---|
| 235 | in* ) |
|---|
| 236 | cat <<EOF |
|---|
| 237 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 238 | configuration management system. |
|---|
| 239 | |
|---|
| 240 | Usage: |
|---|
| 241 | $MYNAME install workingfile [ workingfile ... ] |
|---|
| 242 | |
|---|
| 243 | The install subcommand allows you to roll out a single file from your working |
|---|
| 244 | copy. |
|---|
| 245 | |
|---|
| 246 | EOF |
|---|
| 247 | ;; |
|---|
| 248 | rev* ) |
|---|
| 249 | cat <<EOF |
|---|
| 250 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 251 | configuration management system. |
|---|
| 252 | |
|---|
| 253 | Usage: |
|---|
| 254 | $MYNAME revert workingfile [ workingfile ... ] |
|---|
| 255 | |
|---|
| 256 | The revert subcommand gives you the opportunity to revert to the file before |
|---|
| 257 | you started making changes to it. |
|---|
| 258 | |
|---|
| 259 | EOF |
|---|
| 260 | ;; |
|---|
| 261 | rm ) |
|---|
| 262 | cat <<EOF |
|---|
| 263 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 264 | management system. |
|---|
| 265 | |
|---|
| 266 | Usage: |
|---|
| 267 | $MYNAME rm file |
|---|
| 268 | |
|---|
| 269 | The remove subcommand removes a file from version control It will NOT remove |
|---|
| 270 | the file from the live filesystem. |
|---|
| 271 | |
|---|
| 272 | EOF |
|---|
| 273 | ;; |
|---|
| 274 | mk* ) |
|---|
| 275 | cat <<EOF |
|---|
| 276 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 277 | management system. |
|---|
| 278 | |
|---|
| 279 | Usage: |
|---|
| 280 | $MYNAME mkdir directory |
|---|
| 281 | |
|---|
| 282 | This command will create a new version-controlled directory in your working |
|---|
| 283 | copy. Parent directories do not have to exist; they will be created |
|---|
| 284 | automagically. This command only affects your working copy. It does not commit |
|---|
| 285 | the change. |
|---|
| 286 | |
|---|
| 287 | EOF |
|---|
| 288 | ;; |
|---|
| 289 | ls ) |
|---|
| 290 | cat<<EOF |
|---|
| 291 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 292 | management system. |
|---|
| 293 | |
|---|
| 294 | Usage: |
|---|
| 295 | $MYNAME ls [ file | directory ] |
|---|
| 296 | |
|---|
| 297 | The ls subcommand lists out the contents, in modified long form, of the |
|---|
| 298 | current working directory. If a file or directory is specified, it will list |
|---|
| 299 | that instead. |
|---|
| 300 | |
|---|
| 301 | EOF |
|---|
| 302 | ;; |
|---|
| 303 | lsattr ) |
|---|
| 304 | cat<<EOF |
|---|
| 305 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 306 | management system. |
|---|
| 307 | |
|---|
| 308 | Usage: |
|---|
| 309 | $MYNAME lsattr [ file | directory ] |
|---|
| 310 | |
|---|
| 311 | The lsattr subcommand lists out the confman attributes of files in the |
|---|
| 312 | repository. These attributes can be used to store information such as |
|---|
| 313 | file permissions, ownership, comment characters, syntax checkers, and |
|---|
| 314 | even commands to execute when changing the file. |
|---|
| 315 | |
|---|
| 316 | EOF |
|---|
| 317 | ;; |
|---|
| 318 | chattr ) |
|---|
| 319 | cat<<EOF |
|---|
| 320 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 321 | management system. |
|---|
| 322 | |
|---|
| 323 | Usage: |
|---|
| 324 | $MYNAME chattr attribute value [ file | directory ] |
|---|
| 325 | |
|---|
| 326 | The chattr subcommand alters the confman attributes of files in the |
|---|
| 327 | repository. These attributes can be used to store information such as |
|---|
| 328 | file permissions, ownership, comment characters, syntax checkers, and |
|---|
| 329 | even commands to execute when changing the file. |
|---|
| 330 | |
|---|
| 331 | EOF |
|---|
| 332 | ;; |
|---|
| 333 | rmattr ) |
|---|
| 334 | cat<<EOF |
|---|
| 335 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 336 | management system. |
|---|
| 337 | |
|---|
| 338 | Usage: |
|---|
| 339 | $MYNAME rmattr attribute [ file | directory ] |
|---|
| 340 | |
|---|
| 341 | The rmattr subcommand removes the confman attributes of files in the |
|---|
| 342 | repository. These attributes can be used to store information such as |
|---|
| 343 | file permissions, ownership, comment characters, syntax checkers, and |
|---|
| 344 | even commands to execute when changing the file. |
|---|
| 345 | |
|---|
| 346 | EOF |
|---|
| 347 | ;; |
|---|
| 348 | cho* ) |
|---|
| 349 | cat <<EOF |
|---|
| 350 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 351 | management system. |
|---|
| 352 | |
|---|
| 353 | Usage: |
|---|
| 354 | $MYNAME chown [ -R ] owner [ file | directory ] |
|---|
| 355 | |
|---|
| 356 | The chown command works like it's unix equivalent. It does not support |
|---|
| 357 | user:group notation. The only option it will take is -R for recursive. |
|---|
| 358 | |
|---|
| 359 | EOF |
|---|
| 360 | ;; |
|---|
| 361 | chg* ) |
|---|
| 362 | cat <<EOF |
|---|
| 363 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 364 | management system. |
|---|
| 365 | |
|---|
| 366 | Usage: |
|---|
| 367 | $MYNAME chgrp group [ file | directory ] |
|---|
| 368 | |
|---|
| 369 | The chgrp command works like it's unix equivalent. The only option it will take |
|---|
| 370 | is -R for recursive. |
|---|
| 371 | |
|---|
| 372 | EOF |
|---|
| 373 | ;; |
|---|
| 374 | chm* ) |
|---|
| 375 | cat <<EOF |
|---|
| 376 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 377 | management system. |
|---|
| 378 | |
|---|
| 379 | Usage: |
|---|
| 380 | $MYNAME chmod mode [ file | directory ] |
|---|
| 381 | |
|---|
| 382 | The chmod command works like it's unix equivalent. Note that it will only |
|---|
| 383 | accept octets as permissions -- it will not interpret symbolic permissions |
|---|
| 384 | correctly. The only option it will take is -R for recursive. |
|---|
| 385 | |
|---|
| 386 | EOF |
|---|
| 387 | ;; |
|---|
| 388 | chc* ) |
|---|
| 389 | cat <<EOF |
|---|
| 390 | $MYNAME provides a command-line interface to Rescomp's server configuration |
|---|
| 391 | management system. |
|---|
| 392 | |
|---|
| 393 | Usage: |
|---|
| 394 | $MYNAME chcom comment-character [ file | directory ] |
|---|
| 395 | |
|---|
| 396 | The chcom subcommand takes a file or directory as an argument and changes the |
|---|
| 397 | comment string associated with it. This will typically only be useful when |
|---|
| 398 | confman has guessed the comment character of your file incorrectly. |
|---|
| 399 | |
|---|
| 400 | EOF |
|---|
| 401 | ;; |
|---|
| 402 | checkl* ) |
|---|
| 403 | cat <<EOF |
|---|
| 404 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 405 | configuration management system. |
|---|
| 406 | |
|---|
| 407 | Usage: |
|---|
| 408 | $MYNAME checklook module |
|---|
| 409 | |
|---|
| 410 | The checklook command peeks into the checkpoints for the specified module |
|---|
| 411 | and gives you a listing of current checkpoints with some other cool info. |
|---|
| 412 | This command does not alter the repository. |
|---|
| 413 | |
|---|
| 414 | EOF |
|---|
| 415 | ;; |
|---|
| 416 | checkn* ) |
|---|
| 417 | cat <<EOF |
|---|
| 418 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 419 | configuration management system. |
|---|
| 420 | |
|---|
| 421 | Usage: |
|---|
| 422 | $MYNAME checknew module name |
|---|
| 423 | |
|---|
| 424 | The newcheck command creates a named checkpoint for the specified module. |
|---|
| 425 | This change is committed to the repository immediately. |
|---|
| 426 | |
|---|
| 427 | EOF |
|---|
| 428 | ;; |
|---|
| 429 | checkc* ) |
|---|
| 430 | cat <<EOF |
|---|
| 431 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 432 | configuration management system. |
|---|
| 433 | |
|---|
| 434 | Usage: |
|---|
| 435 | $MYNAME checkclear module name |
|---|
| 436 | |
|---|
| 437 | The rmcheck command clears a named checkpoint from the specified module. |
|---|
| 438 | This change is committed to the repository immediately. |
|---|
| 439 | |
|---|
| 440 | EOF |
|---|
| 441 | ;; |
|---|
| 442 | ro* ) |
|---|
| 443 | cat <<EOF |
|---|
| 444 | $MYNAME provides a command-line interface to Rescomp's server |
|---|
| 445 | configuration management system. |
|---|
| 446 | |
|---|
| 447 | Usage: |
|---|
| 448 | $MYNAME rollback module [ checkpoint | YYYYMMDD [HHMM] ] |
|---|
| 449 | |
|---|
| 450 | The rollback command first rolls your working copy of module back to the |
|---|
| 451 | named checkpoint. You can optionally roll-back to a specific point in time |
|---|
| 452 | using a date (and optionally time) as specified in the usage statement. |
|---|
| 453 | This change is immediately committed to the repository. |
|---|
| 454 | |
|---|
| 455 | After the rollback is complete, we perform the equivalent of a: |
|---|
| 456 | $MYNAME commit |
|---|
| 457 | |
|---|
| 458 | EOF |
|---|
| 459 | ;; |
|---|
| 460 | * ) |
|---|
| 461 | print_usage 1 |
|---|
| 462 | ;; |
|---|
| 463 | esac |
|---|
| 464 | exit $2 |
|---|
| 465 | } |
|---|
| 466 | |
|---|
| 467 | |
|---|
| 468 | |
|---|