]>
git.proxmox.com Git - pve-docs.git/blob - doc-debian/pve-docs-mediawiki-import
11 my $config_fn = "/root/.pve-docs"; # format 'username:pw'
13 my $fh = IO
::File-
>new("$config_fn") ||
14 die "Please configure the mediawiki user/passswd in '$config_fn'\n";
16 my $api_url = "http://localhost/api.php";
21 my ($username, $passwd) = split(':', $config, 2);
23 my $mw = MediaWiki
::API-
>new();
24 $mw->{config
}->{api_url
} = $api_url;
27 $mw->login({ lgname
=> $username, lgpassword
=> $passwd })
28 || die $mw->{error
}->{code
} . ': ' . $mw->{error
}->{details
};
31 my ($pagename, $include, $category) = @_;
33 print "update mediawiki page: $pagename\n";
35 my $ref = $mw->get_page( { title
=> $pagename } );
36 my $page = $ref->{'*'} || '';
38 if ($page !~ m/^\{\{#pvedocs:.*\}\}\s*$/m) {
39 $page = "{{#pvedocs:$include}}\n$page";
41 $page =~ s/^\{\{#pvedocs:.*\}\}\s*$/\{\{#pvedocs:$include\}\}\n/m;
45 my $catstr = "Category:$category";
47 if ($page !~ m/^\[\[$catstr\]\]\s*$/m) {
48 $page .= "\n[[$catstr]]\n";
52 my $timestamp = $ref->{timestamp
};
56 basetimestamp
=> $timestamp, # to avoid edit conflicts
61 die $mw->{error
}->{code
} . ': ' . $mw->{error
}->{details
};
64 my $cat_refdoc = "Reference Documentation";
67 'chapter-ha-manager-plain.html' => {
68 title
=> "High Availability",
69 category
=> $cat_refdoc,
71 'chapter-sysadmin-plain.html' => {
72 title
=> "Host System Administration",
73 category
=> $cat_refdoc,
75 'chapter-pct-plain.html' => {
76 title
=> "Linux Container",
77 category
=> $cat_refdoc,
79 'chapter-pmxcfs-plain.html' => {
80 title
=> "Proxmox Cluster File System (pmxcfs)",
81 category
=> $cat_refdoc,
83 'chapter-pve-bibliography-plain.html' => {
84 title
=> "Bibliography",
85 category
=> $cat_refdoc,
87 'chapter-pvecm-plain.html' => {
88 title
=> "Cluster Manager",
89 category
=> $cat_refdoc,
91 'chapter-pve-faq-plain.html' => {
93 category
=> $cat_refdoc,
95 'chapter-pve-firewall-plain.html' => {
97 category
=> $cat_refdoc,
99 'chapter-pvesm-plain.html' => {
101 category
=> $cat_refdoc,
103 'chapter-pveum-plain.html' => {
104 title
=> "User Management",
105 category
=> $cat_refdoc,
107 'chapter-qm-plain.html' => {
108 title
=> "Qemu/KVM Virtual Machines",
109 category
=> $cat_refdoc,
111 'chapter-vzdump-plain.html' => {
112 title
=> "Backup and Restore",
113 category
=> $cat_refdoc,
117 #update_page("testpage1", $filename, $d->{category});
119 foreach my $filename (keys %$docs) {
120 my $path = "/usr/share/pve-docs/$filename";
121 die "no such file '$path'" if ! -f
$path;
122 my $d = $docs->{$filename};
123 update_page
($d->{title
}, $filename, $d->{category
});