Changeset 622
- Timestamp:
- Apr 21, 2007, 2:33:29 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/cfgmgr.cmd
r580 r622 34 34 call Init 35 35 36 /* 36 37 call DeleteObsoleteFiles 38 */ 37 39 38 40 parse arg args … … 47 49 signal NormalExit 48 50 49 action_taken = 051 cfg.action_taken = 0 50 52 do f = 1 to cfg.file.0 51 53 file_exists = stream(cfg.file.f.name, 'c' , 'query exists') 52 if cfg. delete = 1then54 if cfg.operation = 'INSTALL' then 53 55 if file_exists \= '' then 54 56 do 55 'del 'cfg.file.f.name 56 action_taken = 1 57 if FilesAreDifferent(cfg.file.f.default, cfg.file.f.name) = 1 then 58 if cfg.defaults = 1 then 59 do 60 call SysMkDir cfg.backupdir 61 if cfg.unattended = 0 then 62 do 63 user_choice = PromptForReplaceOption(f) 64 if user_choice == 'Q' then 65 signal NormalExit 66 if user_choice == 'N' then 67 iterate 68 end 69 /* unattended = 1 or user_choice = 'Y' */ 70 cfg.errorcode = CfgAction( 'RESETTODEFAULT', f ) 71 end 57 72 end 58 73 else 59 nop 60 else 61 /* must be a "reset" operation */ 62 select 63 when file_exists == '' then /* If file is missing... */ 74 cfg.errorcode = CfgAction( 'INSTALLDEFAULT', f ) 75 else /* operation = deinstall */ 76 do 77 if BackupFileIsOK(f) = 0 then 78 iterate 79 if cfg.unattended = 0 then 64 80 do 65 'copy 'cfg.file.f.tmpl8 cfg.file.f.name 66 action_taken = 1 81 user_choice = PromptForReplaceOption(f) 82 if user_choice == 'Q' then 83 signal NormalExit 84 if user_choice == 'N' then 85 iterate 67 86 end 68 when cfg.reset_overwrite == 1 then 69 if FilesAreDifferent(cfg.file.f.tmpl8, cfg.file.f.name) == 1 then 70 if cfg.unattended == 1 | , /* If unattended reset, or */ 71 cfg.reset_overwrite_option == 'A' then /* user has wants "ALL" overwrites... */ 72 do 73 'copy 'cfg.file.f.tmpl8 cfg.file.f.name 74 action_taken = 1 75 end 76 else 77 if PromptedReset(f) == 'Y' then /* If user has OK'd this overwrite... */ 78 do 79 'copy 'cfg.file.f.tmpl8 cfg.file.f.name 80 action_taken = 1 81 end 82 otherwise 83 nop 87 cfg.errorcode = CfgAction('DEINSTALL', f) 88 if cfg.errorcode \= 0 then 89 leave 84 90 end 85 91 end … … 87 93 if cfg.errorcode \= 0 then 88 94 signal ErrorExit 89 if action_taken = 0 then 95 96 if cfg.action_taken = 0 then 90 97 do 98 say 99 say 'No action taken.' 91 100 say 92 101 say 'FM/2 configuration files are already as you desire.' 93 102 end 103 94 104 signal NormalExit 95 105 … … 117 127 cfg. = '' 118 128 cfg.errorcode = 0 119 cfg. reset_overwrite= 0129 cfg.defaults = 0 120 130 cfg.unattended = 0 121 cfg.delete = 0 131 cfg.backupdir = '.\User_Config_Backup' 132 cfg.actionmethod = 'COPY' /* The default method of backing up and restoring */ 122 133 123 134 f = 0 … … 126 137 127 138 f = f + 1 128 cfg.file.f. tmpl8= '.\Tmplates\assoc.tmp'139 cfg.file.f.default = '.\Tmplates\assoc.tmp' 129 140 cfg.file.f.name = '.\assoc.dat' 130 141 cfg.file.f.desc.1 = 'FM/2 associations' … … 132 143 133 144 f = f + 1 134 cfg.file.f. tmpl8= '.\Tmplates\commands.tmp'145 cfg.file.f.default = '.\Tmplates\commands.tmp' 135 146 cfg.file.f.name = '.\commands.dat' 136 147 cfg.file.f.desc.1 = 'FM/2 user-defined commands' … … 138 149 139 150 f = f + 1 140 cfg.file.f. tmpl8= '.\Tmplates\archiver.tmp'151 cfg.file.f.default = '.\Tmplates\archiver.tmp' 141 152 cfg.file.f.name = '.\archiver.bb2' 142 153 cfg.file.f.desc.1 = 'FM/2 archiver definitions' … … 144 155 145 156 f = f + 1 146 cfg.file.f. tmpl8= '.\Tmplates\cmds.tmp'157 cfg.file.f.default = '.\Tmplates\cmds.tmp' 147 158 cfg.file.f.name = '.\cmds.tls' 148 159 cfg.file.f.desc.1 = 'FM/2 toolbar: commands' … … 150 161 151 162 f = f + 1 152 cfg.file.f. tmpl8= '.\Tmplates\files.tmp'163 cfg.file.f.default = '.\Tmplates\files.tmp' 153 164 cfg.file.f.name = '.\files.tls' 154 165 cfg.file.f.desc.1 = 'FM/2 toolbar: files' … … 156 167 157 168 f = f + 1 158 cfg.file.f. tmpl8= '.\Tmplates\select.tmp'169 cfg.file.f.default = '.\Tmplates\select.tmp' 159 170 cfg.file.f.name = '.\select.tls' 160 171 cfg.file.f.desc.1 = 'FM/2 toolbar: select' … … 162 173 163 174 f = f + 1 164 cfg.file.f. tmpl8= '.\Tmplates\sort.tmp'175 cfg.file.f.default = '.\Tmplates\sort.tmp' 165 176 cfg.file.f.name = '.\sort.tls' 166 177 cfg.file.f.desc.1 = 'FM/2 toolbar: sort' … … 168 179 169 180 f = f + 1 170 cfg.file.f. tmpl8= '.\Tmplates\utils.tmp'181 cfg.file.f.default = '.\Tmplates\utils.tmp' 171 182 cfg.file.f.name = '.\utils.tls' 172 183 cfg.file.f.desc.1 = 'FM/2 toolbar: utils' … … 174 185 175 186 f = f + 1 176 cfg.file.f. tmpl8= '.\Tmplates\views.tmp'187 cfg.file.f.default = '.\Tmplates\views.tmp' 177 188 cfg.file.f.name = '.\views.tls' 178 189 cfg.file.f.desc.1 = 'FM/2 toolbar: views' … … 180 191 181 192 f = f + 1 182 cfg.file.f. tmpl8= '.\Tmplates\config.tmp'193 cfg.file.f.default = '.\Tmplates\config.tmp' 183 194 cfg.file.f.name = '.\config.tls' 184 195 cfg.file.f.desc.1 = 'FM/2 toolbar: config' … … 186 197 187 198 f = f + 1 188 cfg.file.f. tmpl8= '.\Tmplates\fm3tools.tmp'199 cfg.file.f.default = '.\Tmplates\fm3tools.tmp' 189 200 cfg.file.f.name = '.\fm3tools.dat' 190 201 cfg.file.f.desc.1 = 'FM/2 toolbar: tools?' … … 192 203 193 204 f = f + 1 194 cfg.file.f. tmpl8= '.\Tmplates\filters.tmp'205 cfg.file.f.default = '.\Tmplates\filters.tmp' 195 206 cfg.file.f.name = '.\filters.dat' 196 207 cfg.file.f.desc.1 = 'FM/2 filters' … … 198 209 199 210 f = f + 1 200 cfg.file.f. tmpl8= '.\Tmplates\quicktls.tmp'211 cfg.file.f.default = '.\Tmplates\quicktls.tmp' 201 212 cfg.file.f.name = '.\quicktls.dat' 202 213 cfg.file.f.desc.1 = 'FM/2 toolbar list' … … 204 215 205 216 f = f + 1 206 cfg.file.f. tmpl8= '.\Tmplates\fatopt.tmp'217 cfg.file.f.default = '.\Tmplates\fatopt.tmp' 207 218 cfg.file.f.name = '.\fatopt.cmd' 208 219 cfg.file.f.desc.1 = 'FM/2 FAT optimizing command' … … 210 221 211 222 f = f + 1 212 cfg.file.f. tmpl8= '.\Tmplates\hpfsopt.tmp'223 cfg.file.f.default = '.\Tmplates\hpfsopt.tmp' 213 224 cfg.file.f.name = '.\hpfsopt.cmd' 214 225 cfg.file.f.desc.1 = 'FM/2 HPFS optimizing command' … … 216 227 217 228 f = f + 1 218 cfg.file.f. tmpl8= '.\Tmplates\jfsopt.tmp'229 cfg.file.f.default = '.\Tmplates\jfsopt.tmp' 219 230 cfg.file.f.name = '.\jfsopt.cmd' 220 231 cfg.file.f.desc.1 = 'FM/2 JFS optimizing command' … … 243 254 parse var args param args 244 255 select 245 when param = '/ RESET' then246 if cfg. delete = 1then256 when param = '/INSTALL' then 257 if cfg.operation \= '' then 247 258 cfg.errorcode = 1 248 259 else 249 cfg. reset_overwrite = 1250 when param = '/DE LETE' then251 if cfg. reset_overwrite = 1then260 cfg.operation = 'INSTALL' 261 when param = '/DEINSTALL' then 262 if cfg.operation \= '' then 252 263 cfg.errorcode = 1 253 264 else 254 cfg. delete = 1265 cfg.operation = 'DEINSTALL' 255 266 when param = '/UNATTENDED' then 256 267 cfg.unattended = 1 268 when param = '/DEFAULTS' then 269 cfg.defaults = 1 257 270 otherwise 258 271 cfg.errorcode = 2 259 272 end 260 273 end 274 if cfg.operation = '' then 275 cfg.errorcode = 1 276 else 277 if cfg.operation = 'INSTALL' & cfg.defaults = 0 then 278 cfg.unattended = 1 261 279 return 262 280 263 281 GetUserOptions: procedure expose (globals) 264 if cfg.reset_overwrite = 1 then 282 call SysCls 283 option = '' 284 if cfg.defaults = 1 then 265 285 do 266 /* messages here about reset */ 267 call SysCls 268 do while wordpos(cfg.reset_overwrite_option, 'A C Q') == 0 286 do while wordpos(option, 'A C Q') == 0 269 287 say 270 288 say … … 278 296 say 'This program can ask for confirmation before each file,' 279 297 say 'if it already exists, is replaced with its default.' 280 cfg.reset_overwrite_option = GetResponse('Type ''A'' for ALL files, ''C'' for Confirmations, ''Q'' to quit') 298 say 299 option = GetResponse('Type ''A'' for ALL files, ''C'' for Confirmations, ''Q'' to quit') 281 300 end 282 cfg.userabort = ( cfg.reset_overwrite_option == 'Q')283 if cfg.reset_overwrite_option == 'A' then301 cfg.userabort = (option == 'Q') 302 if option == 'A' then 284 303 do 285 304 say 286 305 say 287 say center(copies(' ** Warning!! ** ', 3), cfg.screen_width)306 say '**** WARNING ****' || copies(d2c(7), 3) 288 307 say 289 308 say 'You have chosen to replace ALL configuration files with' 290 309 say 'default values.' 291 cfg.userabort = (GetResponse('Type ''Y'' to proceed, anthing else cancels') \= 'Y') 310 say 311 if GetResponse('Type ''Y'' to proceed, anthing else cancels') = 'Y' then 312 cfg.unattended = 1 313 else 314 cfg.userabort = 1 292 315 end 293 316 end 294 317 else 295 if cfg. delete = 1then318 if cfg.operation = 'DEINSTALL' then 296 319 do 297 320 /* messages here about delete */ 298 321 call SysCls 299 322 say 300 say center(copies(' ** Warning!! ** ', 3), cfg.screen_width)323 say '**** WARNING ****' || copies(d2c(7), 3) 301 324 say 302 325 say 'If you provide your consent, this program will' 303 326 say 'DELETE all FM/2 configuration files.' 304 327 say 305 cfg.userabort = (GetResponse('Type ''Y'' to proceed, anthing else cancels') \= 'Y') 328 if GetResponse('Type ''Y'' to proceed, anthing else cancels') = 'Y' then 329 cfg.unattended = 1 330 else 331 cfg.userabort = 1 306 332 end 307 333 return … … 309 335 GetResponse: procedure 310 336 parse arg prompt 311 say312 337 call charout , prompt || ': ' 313 338 reply = translate(strip(SysGetKey())) … … 315 340 return reply 316 341 342 /* 317 343 DeleteObsoleteFiles: procedure expose (globals) 318 344 i = 0 … … 338 364 end 339 365 return 366 */ 340 367 341 368 FilesAreDifferent: procedure … … 355 382 return retval 356 383 357 Prompt edReset: procedure expose (globals)384 PromptForReplaceOption: procedure expose (globals) 358 385 parse arg f 386 filename = filespec('N', cfg.file.f.name) 359 387 call SysCls 360 388 say … … 363 391 say 364 392 say 'File:' 365 say ' ' substr(cfg.file.f.name, lastpos('\', cfg.file.f.name) + 1)393 say ' 'filename 366 394 say 367 395 say 'Description:' … … 370 398 end 371 399 say 372 return GetResponse('Type ''Y'' to reset to default') 400 if cfg.operation = 'INSTALL' then 401 do 402 say 'Back up and then overwrite your current 'filename 403 msg = 'with default values' 404 end 405 else 406 msg = 'Replace your current 'filename' with the backup file' 407 return GetResponse(msg '(Y/n)?') 408 409 novalue: 410 say 'Unitialized variable: 'condition('D')' found on line: 'sigl 411 say 'Line text: 'sourceline(sigl) 412 say 413 say 'Exiting...' 414 signal NormalExit 415 373 416 374 417 Usage: procedure expose (globals) 375 say 'Invalid usage. See below for acceptable calls:' 376 say 377 say cfg.pgmname' <no parameters>' 378 say ' This installs missing configuration files with default values.' 379 say 380 say cfg.pgmname' /RESET' 381 say ' This replaces existing configuration files with default values.' 382 say ' You asked to confirm this action. You can choose to replace all' 383 say ' files or you can request a file-by-file confirmation.' 384 say 385 say cfg.pgmname' /DELETE' 386 say ' This deletes all configuration files. You are asked to confirm' 387 say ' this action. (This is not an action users should normally take.)' 388 say 389 say cfg.pgmname' /RESET /UNATTENDED' 390 say cfg.pgmname' /DELETE /UNATTENDED' 391 say ' These operations operate as above except there is NO user' 392 say ' interaction or confirmation! Use with extreme care!' 393 say 418 say 'Proper usage of 'cfg.pgmname':' 419 say 420 say cfg.pgmname' /INSTALL [/UNATTENDED]' 421 say ' This installs any missing configuration files with default values.' 422 say 423 say cfg.pgmname' /INSTALL /DEFAULTS [/UNATTENDED]' 424 say ' This action backs up user-modified configuration files and replaces' 425 say ' them with default values. Unless /UNATTENDED, you are asked to confirm' 426 say ' this action.' 427 say 428 say cfg.pgmname' /DEINSTALL /DEFAULTS [/UNATTENDED]' 429 say ' This reverses the action described above.' 430 say 431 say cfg.pgmname' /DEINSTALL [/UNATTENDED]' 432 say ' This deletes all configuration files. Unless /UNATTENDED, you are asked' 433 say ' to confirm this action. (This is action is automatically done during' 434 say ' de-installation of FM/2. It is not an action users should normally take.)' 435 say 436 say 'The optional parameter /UNATTENDED means there will be NO user interaction' 437 say ' interaction during or confirmation of the operation!!!' 394 438 say 'The order of the parameters is not important.' 395 439 return … … 402 446 say 'If this error continues after re-installing FM/2, contact FM/2 support' 403 447 say 'through the FM2USER group on Yahoo.' 404 return 448 exit 405 449 406 450 novalue: … … 410 454 signal ErrorExit 411 455 456 CfgAction: procedure expose (globals) 457 parse arg action, f 458 retval = 0 459 select 460 when action = 'RESETTODEFAULT' then 461 select 462 when cfg.actionmethod = 'COPY' then 463 do 464 'copy 'cfg.file.f.name cfg.backupdir 465 'copy 'cfg.file.f.default cfg.file.f.name 466 cfg.action_taken = 1 467 end 468 /* Implement other archive/restore methods here */ 469 otherwise 470 retval = 4 471 end 472 when action = 'INSTALLDEFAULT' then 473 select 474 when cfg.actionmethod = 'COPY' then 475 do 476 'copy 'cfg.file.f.default cfg.file.f.name 477 cfg.action_taken = 1 478 end 479 /* Implement other archive/restore methods here */ 480 otherwise 481 retval = 4 482 end 483 when action = 'DEINSTALL' then 484 if cfg.defaults = 1 then 485 select 486 when cfg.actionmethod = 'COPY' then 487 do 488 'copy 'cfg.backupdir || '\' || cfg.file.f.name' .' 489 cfg.action_taken = 1 490 end 491 /* Implement other archive/restore methods here */ 492 otherwise 493 retval = 4 494 end 495 else 496 select 497 when cfg.actionmethod = 'COPY' then 498 if stream(cfg.file.f.name, 'c', 'query exists') \= '' then 499 if FilesAreDifferent(cfg.file.f.name, cfg.file.f.default) = 0 then 500 do 501 'del 'cfg.file.f.name 502 cfg.action_taken = 1 503 end 504 /* Implement other archive/restore methods here */ 505 otherwise 506 retval = 4 507 end 508 otherwise 509 retval = 5 510 511 end 512 return retval 513 514 BackupFileIsOK: procedure expose (globals) 515 parse arg f 516 retval = 1 /* assume yes */ 517 if cfg.defaults = 1 then /* Not needed when cfg.defaults = 0 */ 518 do 519 retval = 0 520 select 521 when cfg.actionmethod = 'COPY' then 522 do 523 backup_file = cfg.backupdir || '\' || cfg.file.f.name 524 if stream(backup_file, 'c', 'query exists') \= '' then 525 retval = FilesAreDifferent(cfg.file.f.name, backup_file) 526 end 527 /* Implement other archive/restore methods here */ 528 otherwise 529 cfg.errorcode = 4 530 end 531 end 532 return retval 533
Note:
See TracChangeset
for help on using the changeset viewer.