1
0

conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #!/bin/rc
  2. # THIS FILE IS AUTOMATICALLY GENERATED
  3. # FROM /sys/src/cmd/fossil/conf.rc. DO NOT EDIT.
  4. # the fossil configuration is stored at the 127kB offset in the disk
  5. # and extends for at most 1 kB.
  6. rfork e
  7. fn usage {
  8. echo 'usage: fossil/conf [-w] /dev/sdC0/fossil [config]' >[1=2]
  9. exit usage
  10. }
  11. wflag=no
  12. while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
  13. switch($1){
  14. case -w
  15. wflag=yes
  16. case *
  17. usage
  18. }
  19. shift
  20. }
  21. if(~ $1 --)
  22. shift
  23. if(~ $wflag no && ! ~ $#* 1)
  24. usage
  25. if(~ $wflag yes && ! ~ $#* 1 2)
  26. usage
  27. disk=$1
  28. if(! test -f $disk){
  29. echo 'unknown disk' $1 >[1=2]
  30. exit nodisk
  31. }
  32. fn sigexit {
  33. rm -f /tmp/fossilconf.$pid
  34. }
  35. if(~ $wflag yes){
  36. {echo fossil config; cat $2} >/tmp/fossilconf.$pid || exit oops
  37. if(! test -s /tmp/fossilconf.$pid){
  38. echo 'config is empty; will not install' >[1=2]
  39. exit emptyconfig
  40. }
  41. if(test `{ls -l /tmp/fossilconf.$pid | awk '{print $6}'} -gt 1024){
  42. echo 'config is too long; max is a little less than a kilobyte' >[1=2]
  43. exit toolong
  44. }
  45. dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 \
  46. >/tmp/_fossilconf.old || exit backup
  47. dd -quiet 1 -count 2 </dev/zero >>/tmp/fossilconf.$pid || exit dd
  48. dd -quiet 1 -bs 1024 -count 1 -if /tmp/fossilconf.$pid \
  49. -trunc 0 -of $disk -oseek 127 || exit dd2
  50. exit 0
  51. }
  52. dd -quiet 1 -bs 1024 -count 1 -if $disk -iseek 127 |
  53. aux/zerotrunc >/tmp/fossilconf.$pid
  54. if(! cmp -s <{sed 1q /tmp/fossilconf.$pid} <{echo fossil config}){
  55. echo 'config has bad header' >[1=2]
  56. exit badconfig
  57. }
  58. sed 1d /tmp/fossilconf.$pid
  59. exit 0