forked from edingc/munki-enroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.php
executable file
·131 lines (103 loc) · 4.15 KB
/
server.php
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
<?php
namespace CFPropertyList;
require_once( 'template/CFPropertyList.php' );
// Get the varibles passed by the enroll script
$catalog = $_GET["catalog"];
$area = $_GET["area"];
$room = $_GET["room"];
$asset = $_GET["asset"];
$hostname = $_GET["hostname"];
// Create manifest for catalog
//
if ( file_exists( '../manifests/' . $catalog . '/' . $catalog . 'Machines' ) )
{
echo "\n";
echo "Manifest for catalog $catalog already exists. \n\n";
}
else
{
echo "\n";
echo "Manifest for catalog $catalog does not exist. Creating ... \n\n";
if ( !is_dir( '../manifests/' . $catalog . '/' ) )
{
mkdir( '../manifests/' . $catalog . '/', 0755, true );
}
// Create the new manifest plist
$plist = new CFPropertyList();
$plist->add( $dict = new CFDictionary() );
// Save the newly created plist
$plist->saveXML( '../manifests/' . $catalog . '/' . $catalog . 'Machines' );
}
// Create manifest for area
//
if ( file_exists( '../manifests/' . $catalog . '/' . $area . '/' . $area ) )
{
echo "Manifest for area $area already exists. \n\n";
}
else
{
echo "Manifest for area $area does not exist. Creating ... \n\n";
if ( !is_dir( '../manifests/' . $catalog . '/' . $area . '/' ) )
{
mkdir( '../manifests/' . $catalog . '/' . $area . '/', 0755, true );
}
// Create the new manifest plist
$plist = new CFPropertyList();
$plist->add( $dict = new CFDictionary() );
// Add parent manifest to included_manifests to achieve waterfall effect
$dict->add( 'included_manifests', $array = new CFArray() );
$array->add( new CFString( $catalog . '/' . $catalog . 'Machines' ) );
// Save the newly created plist
$plist->saveXML( '../manifests/' . $catalog . '/' . $area . '/' . $area );
}
// Create manifest for Room
//
if ( file_exists( '../manifests/' . $catalog . '/' . $area . '/' . $area . $room ) )
{
echo "";
echo "Manifest for room $room already exists. \n\n";
echo "";
}
else
{
echo "";
echo "Manifest for room $room does not exist. Creating ... \n\n";
echo "";
if ( !is_dir( '../manifests/' . $catalog . '/' . $area . '/' ) )
{
mkdir( '../manifests/' . $catalog . '/' . $area . '/' , 0755, true );
}
// Create the new manifest plist
$plist = new CFPropertyList();
$plist->add( $dict = new CFDictionary() );
// Add parent manifest to included_manifests to achieve waterfall effect
$dict->add( 'included_manifests', $array = new CFArray() );
$array->add( new CFString( $catalog . '/' . $catalog . 'Machines' ) );
$array->add( new CFString( $catalog . '/' . $area . '/' . $area ) );
// Save the newly created plist
$plist->saveXML( '../manifests/' . $catalog . '/' . $area . '/' . $area . $room );
}
// Create manifest for a single machine and set it
//
if ( file_exists( '../manifests/' . $catalog . '/' . $area . '/' . $hostname ) )
{
echo "Manifest for machine $hostname already exists. \n\n";
}
else
{
echo "Manifest for machine $hostname does not exist. Creating ... \n\n";
// Create the new manifest plist
$plist = new CFPropertyList();
$plist->add( $dict = new CFDictionary() );
// Add catalog catalog
$dict->add( 'catalogs', $array = new CFArray() );
$array->add( new CFString( $catalog ) );
// Add parent manifest to included_manifests to achieve waterfall effect
$dict->add( 'included_manifests', $array = new CFArray() );
$array->add( new CFString( $catalog . '/' . $catalog . 'Machines' ) );
$array->add( new CFString( $catalog . '/' . $area . '/' . $area ) );
$array->add( new CFString( $catalog . '/' . $area . '/' . $area . $room ) );
// Save the newly created plist
$plist->saveXML( '../manifests/' . $catalog . '/' . $area . '/' . $hostname );
}
?>