-
Notifications
You must be signed in to change notification settings - Fork 0
/
setupFolders.ps1
executable file
·88 lines (68 loc) · 2.07 KB
/
setupFolders.ps1
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
#! /snap/bin/pwsh
$names = (dir -Directory /etc/nginx/pki | where Name -like "*.*").name
foreach($n in $names)
{
#New-Item -ItemType Directory -Path "/var/www/" -Name $($n) -ErrorAction SilentlyContinue
#New-Item -ItemType Directory -Path "/etc/nginx/pki/" -Name $($n) -ErrorAction SilentlyContinue
$html = @"
<!DOCTYPE html>
<html>
<head>
<title>Welcome to the Lab</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to the Lab</h1>
<p>If you see this page, you have reached the web server on $($n).</p>
</body>
</html>
"@
#Write-Host $html
$html | Out-File -FilePath "/var/www/$($n)/index.html" -Force -Encoding ascii
}
#cps folder probalby empty but needed for nginx to statrt
mkdir "/var/www/cps.pkilab.markgamache.com"
#folder for client certs and keys will allow dir listing
mkdir "/var/www/clientcerts.pkilab.markgamache.com"
#instructions
mkdir "/var/www/instructions.pkilab.markgamache.com"
$instHTML = @"
<!DOCTYPE html>
<html>
<head>
<title>Welcome to the Lab</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to the Lab</h1>
<h2>These are the URLs of pain. Diagnose them please</h2>
<br><br>
reference.pkilab.markgamache.com should be working 100% and is meant to test your tools
<br><br>
<a href=`"http://pki.pkilab.markgamache.com/_LabRoot.crt`" target=`"_blank`" rel=`"noopener noreferrer`">Lab Root Cert. Be careful. It is scary insecure</a><br><br>
<a href=`"http://clientcerts.pkilab.markgamache.com`" target=`"_blank`" rel=`"noopener noreferrer`" >Client Certs and Keys can be found here</a>
<br><br>
"@
foreach($n in $names)
{
$instHTML += "<a href=`"http://$($n)`" target=`"_blank`" rel=`"noopener noreferrer`" >$($n)</a>"
$instHTML += "<br>"
}
$instHTML += @'
</body>
</html>
'@
$instHTML | Out-File -Encoding ascii -FilePath "/var/www/instructions.pkilab.markgamache.com/index.html"
& chmod -R 777 /var/www/*