]>
git.proxmox.com Git - pve-docs.git/blob - pve-docs-mediawiki-import.in
14 while (<main
::DATA
>) { $data_str .= $_; }
16 my $fileinfo = decode_json
($data_str);
18 my $config_fn = "/root/.pve-docs"; # format 'username:pw'
20 my $fh = IO
::File-
>new("$config_fn") ||
21 die "Please configure the mediawiki user/passswd in '$config_fn'\n";
23 my $api_url = "http://localhost/mediawiki/api.php";
28 my ($username, $passwd) = split(':', $config, 2);
30 my $mw = MediaWiki
::API-
>new();
31 $mw->{config
}->{api_url
} = $api_url;
34 $mw->login({ lgname
=> $username, lgpassword
=> $passwd })
35 || die $mw->{error
}->{code
} . ': ' . $mw->{error
}->{details
};
38 my ($pagename, $include, $category) = @_;
40 print "update mediawiki page: $pagename\n";
42 my $ref = $mw->get_page( { title
=> $pagename } );
43 my $page = $ref->{'*'} || '';
45 if ($page !~ m/^\{\{#pvedocs:.*\}\}\s*$/m) {
46 $page = "{{#pvedocs:$include}}\n$page";
48 $page =~ s/^\{\{#pvedocs:.*\}\}\s*$/\{\{#pvedocs:$include\}\}\n/m;
52 my $catstr = "Category:$category";
54 if ($page !~ m/^\[\[$catstr\]\]\s*$/m) {
55 $page .= "\n[[$catstr]]\n";
59 my $timestamp = $ref->{timestamp
};
63 basetimestamp
=> $timestamp, # to avoid edit conflicts
68 die $mw->{error
}->{code
} . ': ' . $mw->{error
}->{details
};
71 my $cat_refdoc = "Reference Documentation";
74 'ha-manager-plain.html' => {
75 title
=> "High Availability",
76 category
=> $cat_refdoc,
78 'pve-installation-plain.html' => {
79 title
=> "Installation",
80 category
=> $cat_refdoc,
82 'pve-usbstick-plain.html' => {
83 title
=> "Install from USB Stick",
84 category
=> $cat_refdoc,
86 'pve-system-requirements-plain.html' => {
87 title
=> "System Requirements",
88 category
=> $cat_refdoc,
90 'getting-help-plain.html' => {
91 title
=> "Getting Help",
92 category
=> $cat_refdoc,
94 'pve-network-plain.html' => {
95 title
=> "Network Configuration",
96 category
=> $cat_refdoc,
98 'pve-disk-health-monitoring-plain.html' => {
99 title
=> "Disk Health Monitoring",
100 category
=> $cat_refdoc,
102 'local-lvm-plain.html' => {
103 title
=> "Logical Volume Manager (LVM)",
104 category
=> $cat_refdoc,
106 'pve-package-repos-plain.html' => {
107 title
=> "Package Repositories",
108 category
=> $cat_refdoc,
110 'system-software-updates-plain.html' => {
111 title
=> "System Software Updates",
112 category
=> $cat_refdoc,
114 'sysadmin-plain.html' => {
115 title
=> "Host System Administration",
116 category
=> $cat_refdoc,
118 'pct-plain.html' => {
119 title
=> "Linux Container",
120 category
=> $cat_refdoc,
122 'pmxcfs-plain.html' => {
123 title
=> "Proxmox Cluster File System (pmxcfs)",
124 category
=> $cat_refdoc,
126 'pve-bibliography-plain.html' => {
127 title
=> "Bibliography",
128 category
=> $cat_refdoc,
130 'pvecm-plain.html' => {
131 title
=> "Cluster Manager",
132 category
=> $cat_refdoc,
134 'pve-faq-plain.html' => {
136 category
=> $cat_refdoc,
138 'pve-firewall-plain.html' => {
140 category
=> $cat_refdoc,
142 'pvesm-plain.html' => {
144 category
=> $cat_refdoc,
146 'pveum-plain.html' => {
147 title
=> "User Management",
148 category
=> $cat_refdoc,
151 title
=> "Qemu/KVM Virtual Machines",
152 category
=> $cat_refdoc,
154 'vzdump-plain.html' => {
155 title
=> "Backup and Restore",
156 category
=> $cat_refdoc,
158 'qm.conf.5-plain.html' => {
159 title
=> "Manual: vm.conf",
160 category
=> $cat_refdoc,
162 'pct.conf.5-plain.html' => {
163 title
=> "Manual: pct.conf",
164 category
=> $cat_refdoc,
166 'datacenter.cfg.5-plain.html' => {
167 title
=> "Manual: datacenter.cfg",
168 category
=> $cat_refdoc,
171 'pve-storage-dir-plain.html' => {
172 title
=> "Storage: Directory",
173 category
=> $cat_refdoc,
175 'pve-storage-glusterfs-plain.html' => {
176 title
=> "Storage: GlusterFS",
177 category
=> $cat_refdoc,
179 'pve-storage-iscsidirect-plain.html' => {
180 title
=> "Storage: User Mode iSCSI",
181 category
=> $cat_refdoc,
183 'pve-storage-iscsi-plain.html' => {
184 title
=> "Storage: iSCSI",
185 category
=> $cat_refdoc,
187 'pve-storage-lvm-plain.html' => {
188 title
=> "Storage: LVM",
189 category
=> $cat_refdoc,
191 'pve-storage-lvmthin-plain.html' => {
192 title
=> "Storage: LVM Thin",
193 category
=> $cat_refdoc,
195 'pve-storage-nfs-plain.html' => {
196 title
=> "Storage: NFS",
197 category
=> $cat_refdoc,
199 'pve-storage-rbd-plain.html' => {
200 title
=> "Storage: RBD",
201 category
=> $cat_refdoc,
203 'pve-storage-zfspool-plain.html' => {
204 title
=> "Storage: ZFS",
205 category
=> $cat_refdoc,
209 my $wiki_man5_pages = {
210 'datacenter.cfg.adoc' => 1,
212 'pct.conf.adoc' => 1,
216 foreach my $source (sort keys %{$fileinfo->{toplevel
}->{wiki
}}) {
217 my $title = $fileinfo->{titles
}->{wiki
}->{$source};
218 my $doctype = $fileinfo->{doctype
}->{wiki
}->{$source};
220 my $suffix = $wiki_man5_pages->{$source} ?
'.5-plain.html' : '-plain.html';
221 my $filename = $source;
222 $filename =~ s/\.adoc//;
223 $filename .= $suffix;
225 my $path = "/usr/share/pve-docs/$filename";
226 die "no such file '$path'" if ! -f
$path;
228 update_page
($title, $filename, category
=> $cat_refdoc);
231 # also update 'Get support' page, because this is used since a long
232 # time and is referenced from outside
233 update_page
("Get support", 'getting-help-plain.html', 'HOWTO');