aboutsummaryrefslogtreecommitdiff
path: root/src/update-2.0.awk
blob: 8f74d904c576801abe33d396f43cb6a7d22138cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
state == 1 && NF == 1 && $1 == "end" {
  print "EOT;"
  state = 0
  next
}
state == 1 { print $0; next }

/[ \t]*#/ { print; next }
NF == 0 { print; next }

{ if (!text) start_line = NR }
/\\$/ { text = text substr($0, 1, length($0)-1); next }
{ if (text) $0 = text $0; text = "" }

$1 == "statistics" { printf("%s;\n", $0); next }

$1 == "syslog-facility" { syslog_facility = $2; next }
$1 == "syslog-tag" { sub(($1 "[ \t]*"),"")
                     syslog_tag = $0
                     next }
$1 == "syslog-print-priority" {
                     sub(($1 "[ \t]*"),"")
                     syslog_print_prio = $0
                     next }

function get_indent(  i, len) {
      len = length($0)
      gsub(/^[ \t]*/,"")
      return len - length($0)
}

function indent(len) {
     while (len--)
        printf(" ")
}

$1 == "file-sweep-time" || $1 == "tar-program" || $1 == "admin-address" ||
  $1 == "from-address" || $1 == "host" || $1 == "database" ||
  $1 == "user" || $1 == "password" ||
  $1 == "source" || $1 == "destination"{
                     len = get_indent()
                     kw = $1
                     sub(($1 "[ \t]*"),"")
 		     indent(len)		
                     printf("%s \"%s\";\n", kw, $0)
		     next
}

$1 == "umask" || $1 == "archive" {
                     len = get_indent()
                     kw = $1
                     sub(($1 "[ \t]*"),"")
		     indent(len)
                     printf("%s %s;\n", kw, $0)
		     next
}

$1 == "project-owner" || $1 == "user-data" || $1 == "verify-user" ||
  $1 == "gpg-key" {
     len = get_indent()
     indent(len)
     printf("access-method %s {\n", $1);
     indent(len + 2)
     printf("type %s;\n", $2)
     if (NF > 2) {
       indent(len + 2)
       printf("params (");
       printf("\"%s\"", $3)
       if (NF > 3) {
	 printf(",\n");
	 indent(len + 10)
	 printf("\"")
         for (i = 4; i < NF; i++) 
           printf("%s ", $i)
         printf("%s\"", $NF)
       }
       print ");"
     }
     indent(len)
     print("}")
     next
}

$1 == "sql" {
     printf("sql %s {\n", $2);
     next
}

$1 == "directory" {
     printf("directory ")
     if (NF > 1)
       printf("%s ", $2)
     print "{"
     next
}
     
$1 == "end" {  print "}"; next }

$1 == "mail-admin-stat" {
  print "mail-statistics {"
  printf("  message @%s;\n", $2);
  if (NF > 2) {
    printf("  statistics");
    for (i = 3; i <= NF; i++)
      printf(" %s", $i)
    print ";"
  }
  print "}"
  next
}  

$1 == "notify-event" {
  printf("notify-event {\n");
  printf("  event %s;\n", $2);
  printf("  recipient %s;\n", $3);
  printf("  message @%s;\n", $4);
  print "}"
  next
}

$1 == "define-message" {
  print "define-message", $2, "<<EOT"
  state = 1
  next  
}    

$1 == "include" {
  printf("#include <%s>\n", $2);
}

END {
   if (syslog_facility || syslog_tag || syslog_print_prio) {
     print "syslog {"
     if (syslog_facility)
       printf("  facility %s;\n", syslog_facility);
     if (syslog_tag)
       printf("  tag %s;\n", syslog_tag);
     if (syslog_print_prio)
       printf("  print-priority %s;\n", syslog_print_prio);
     print "}"
  }
}

Return to:

Send suggestions and report system problems to the System administrator.