Skip to content

Commit 41cfcad

Browse files
committed
Simple HTTP service and add licenses into everything.
1 parent 35f4aa5 commit 41cfcad

11 files changed

+370
-11
lines changed

Makefile

+47-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,29 @@
1+
#
2+
# CDDL HEADER START
3+
#
4+
# The contents of this file are subject to the terms of the
5+
# Common Development and Distribution License, Version 1.0 only
6+
# (the "License"). You may not use this file except in compliance
7+
# with the License.
8+
#
9+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10+
# or http://www.opensolaris.org/os/licensing.
11+
# See the License for the specific language governing permissions
12+
# and limitations under the License.
13+
#
14+
# When distributing Covered Code, include this CDDL HEADER in each
15+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16+
# If applicable, add the following below this CDDL HEADER, with the
17+
# fields enclosed by brackets "[]" replaced with your own identifying
18+
# information: Portions Copyright [yyyy] [name of copyright owner]
19+
#
20+
# CDDL HEADER END
21+
#
22+
#
23+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
24+
# Use is subject to license terms.
25+
#
26+
127
VERSION=r151002
228
BUILDSEND=rpool/kayak_image
329

@@ -7,6 +33,12 @@ BUILDSEND_MP=$(shell zfs get -o value -H mountpoint $(BUILDSEND))
733
all: $(BUILDSEND_MP)/miniroot.gz $(BUILDSEND_MP)/kayak_$(VERSION).zfs.bz2
834
@ls -l $^
935

36+
INSTALLS=anon.dtrace.conf anon.system build_image.sh build_zfs_send.sh \
37+
data/access.log data/boot data/etc data/filelist.ramdisk data/kernel \
38+
data/known_extras data/mdb data/platform disk_help.sh install_help.sh \
39+
install_image.sh Makefile net_help.sh README.md \
40+
sample/000000000000.sample sample/menu.lst.000000000000
41+
1042
TFTP_FILES=$(DESTDIR)/tftpboot/boot/platform/i86pc/kernel/amd64/unix \
1143
$(DESTDIR)/tftpboot/omnios/kayak/miniroot.gz \
1244
$(DESTDIR)/tftpboot/menu.lst \
@@ -43,7 +75,20 @@ $(BUILDSEND_MP)/miniroot.gz: $(MINIROOT_DEPS)
4375

4476
install-dirs:
4577
mkdir -p $(DESTDIR)/tftpboot/boot/platform/i86pc/kernel/amd64
46-
mkdir -p $(DESTDIR)/tftpboot/omnios/kayak
78+
mkdir -p $(DESTDIR)/tftpboot/kayak
4779
mkdir -p $(DESTDIR)/var/kayak/kayak
80+
mkdir -p $(DESTDIR)/usr/share/kayak/data
81+
mkdir -p $(DESTDIR)/var/kayak/log
82+
83+
install-package: install-dirs
84+
for file in $(INSTALLS) ; do \
85+
cp $$file $(DESTDIR)/usr/share/kayak/$$file ; \
86+
done
87+
cp http/svc-kayak /lib/svc/method/svc-kayak
88+
chmod a+x /lib/svc/method/svc-kayakhttp
89+
cp http/kayak.xml /lib/svc/manifest/kayak.xml
4890

49-
install: install-dirs $(TFTP_FILES) $(WEB_FILES)
91+
install: $(TFTP_FILES) $(WEB_FILES) /platform/i86pc/kernel/amd64/unix
92+
cp -p /platform/i86pc/kernel/amd64/unix $(DESTDIR)/tftpboot/boot/platform/i86pc/kernel/amd64/unix
93+
cp -p sample/menu.lst.000000000000 $(DESTDIR)/tftpboot/menu.lst
94+
cp -p $(WEB_FILES) $(DESTDIR)/var/kayak/kayak/

anon.dtrace.conf

+1-3
Large diffs are not rendered by default.

build_image.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/bin/bash
2-
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License, Version 1.0 only
7+
# (the "License"). You may not use this file except in compliance
8+
# with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or http://www.opensolaris.org/os/licensing.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
#
24+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25+
# Use is subject to license terms.
26+
#
327
fail() {
428
echo "ERROR: $*"
529
exit 1

build_zfs_send.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/bin/bash
2-
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License, Version 1.0 only
7+
# (the "License"). You may not use this file except in compliance
8+
# with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or http://www.opensolaris.org/os/licensing.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
#
24+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25+
# Use is subject to license terms.
26+
#
327
fail() {
428
echo $*
529
exit 1

disk_help.sh

+25-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/usr/bin/bash
2-
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License, Version 1.0 only
7+
# (the "License"). You may not use this file except in compliance
8+
# with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or http://www.opensolaris.org/os/licensing.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
#
24+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25+
# Use is subject to license terms.
26+
#
327
ListDisks() {
428
declare -A disksize
529
declare -A diskname

http/kayak.xml

+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
3+
<!--
4+
5+
CDDL HEADER START
6+
7+
The contents of this file are subject to the terms of the
8+
Common Development and Distribution License, Version 1.0 only
9+
(the "License"). You may not use this file except in compliance
10+
with the License.
11+
12+
You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13+
or http://www.opensolaris.org/os/licensing.
14+
See the License for the specific language governing permissions
15+
and limitations under the License.
16+
17+
When distributing Covered Code, include this CDDL HEADER in each
18+
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19+
If applicable, add the following below this CDDL HEADER, with the
20+
fields enclosed by brackets "[]" replaced with your own identifying
21+
information: Portions Copyright [yyyy] [name of copyright owner]
22+
23+
CDDL HEADER END
24+
25+
26+
Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
27+
Use is subject to license terms.
28+
29+
-->
30+
31+
<service_bundle type='manifest' name='SUNWcsr:sac'>
32+
33+
<service
34+
name='network/kayak'
35+
type='service'
36+
version='1'>
37+
38+
<create_default_instance enabled='false' />
39+
40+
<single_instance />
41+
42+
<dependency
43+
name='filesystems'
44+
type='service'
45+
grouping='require_all'
46+
restart_on='none'>
47+
<service_fmri value='svc:/system/filesystem/local' />
48+
</dependency>
49+
50+
<dependency
51+
name='tftp'
52+
type='service'
53+
grouping='require_all'
54+
restart_on='none'>
55+
<service_fmri value='svc:/network/tftp/udp6:default' />
56+
</dependency>
57+
58+
<exec_method
59+
type='method'
60+
name='start'
61+
exec='/lib/svc/method/svc-kayak'
62+
timeout_seconds='60'>
63+
<method_context>
64+
<method_credential user='root' group='root' />
65+
</method_context>
66+
</exec_method>
67+
68+
<exec_method
69+
type='method'
70+
name='stop'
71+
exec=':kill'
72+
timeout_seconds='60'>
73+
</exec_method>
74+
75+
<property_group name='startd' type='framework'>
76+
<propval name='duration' type='astring' value='child' />
77+
<propval name='ignore_error' type='astring'
78+
value='core,signal' />
79+
</property_group>
80+
81+
<stability value='Unstable' />
82+
83+
<template>
84+
<common_name>
85+
<loctext xml:lang='C'>
86+
Kayak Network Installer
87+
</loctext>
88+
</common_name>
89+
</template>
90+
</service>
91+
92+
</service_bundle>

http/svc-kayak

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/python
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License, Version 1.0 only
7+
# (the "License"). You may not use this file except in compliance
8+
# with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or http://www.opensolaris.org/os/licensing.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
#
24+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25+
# Use is subject to license terms.
26+
#
27+
28+
import os.path
29+
import cherrypy
30+
import re
31+
import time
32+
from cherrypy.process.plugins import DropPrivileges
33+
34+
class Root:
35+
@cherrypy.expose
36+
def index(self):
37+
return """<html>
38+
<head>
39+
<title>Minimal Kayak Install Server</title>
40+
</head>
41+
<html>
42+
<body>
43+
<h1>Minimal Kayak Install Server</h1>
44+
</body>
45+
</html>"""
46+
47+
class KayakLog(object):
48+
49+
exposed = True
50+
51+
def PUT(self, macaddr):
52+
if re.match("^[0-9a-fA-F]{12}$", macaddr) == None:
53+
raise cherrypy.HTTPError("404 Not Found")
54+
log = open('/var/kayak/log/' + macaddr + "." + str(time.time()), 'w')
55+
log.write(cherrypy.request.body.read())
56+
57+
if __name__ == '__main__':
58+
current_dir = os.path.dirname(os.path.abspath(__file__))
59+
# Set up site-wide config first so we get a log if errors occur.
60+
cherrypy.config.update({'environment': 'production',
61+
'log.screen': True,
62+
'server.socket_host': '0.0.0.0',
63+
'server.socket_port': 80,
64+
})
65+
66+
conf = {'/': { 'request.dispatch': cherrypy.dispatch.MethodDispatcher(), },
67+
'/kayak': {'tools.staticdir.on': True,
68+
'tools.staticdir.dir': '/var/kayak/kayak'}}
69+
root = Root()
70+
root.kayaklog = KayakLog()
71+
DropPrivileges(cherrypy.engine, uid=60001, gid=60001).subscribe()
72+
cherrypy.quickstart(root, '/', config=conf)

install_help.sh

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,29 @@
11
#!/usr/bin/bash
2-
2+
#
3+
# CDDL HEADER START
4+
#
5+
# The contents of this file are subject to the terms of the
6+
# Common Development and Distribution License, Version 1.0 only
7+
# (the "License"). You may not use this file except in compliance
8+
# with the License.
9+
#
10+
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11+
# or http://www.opensolaris.org/os/licensing.
12+
# See the License for the specific language governing permissions
13+
# and limitations under the License.
14+
#
15+
# When distributing Covered Code, include this CDDL HEADER in each
16+
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17+
# If applicable, add the following below this CDDL HEADER, with the
18+
# fields enclosed by brackets "[]" replaced with your own identifying
19+
# information: Portions Copyright [yyyy] [name of copyright owner]
20+
#
21+
# CDDL HEADER END
22+
#
23+
#
24+
# Copyright 2012 OmniTI Computer Consulting, Inc. All rights reserved.
25+
# Use is subject to license terms.
26+
#
327
LOG_SETUP=0
428

529
ConsoleLog(){
@@ -14,6 +38,10 @@ CopyInstallLog(){
1438
cp $INSTALL_LOG $ALTROOT/var/log/install/kayak.log
1539
fi
1640
}
41+
SendInstallLog(){
42+
PUTURL=`echo $CONFIG | sed -e "s%/kayak/%/kayaklog/%g;"`
43+
curl -T $INSTALL_LOG $PUTURL/$ETHER
44+
}
1745
OutputLog(){
1846
if [[ "$LOG_SETUP" -eq "0" ]]; then
1947
exec 4>/dev/null
@@ -88,7 +116,7 @@ BuildBE() {
88116
[[ -L $ALTROOT/dev/msglog ]] || \
89117
ln -s ../devices/pseudo/sysmsg@0:msglog $ALTROOT/dev/msglog
90118
MakeSwapDump
91-
zfs destroy omnios@kayak
119+
zfs destroy rpool/ROOT/omnios@kayak
92120
}
93121

94122
FetchConfig(){
@@ -181,5 +209,6 @@ RunInstall(){
181209
ApplyChanges || bomb "Could not apply all configuration changes"
182210
MakeBootable || bomb "Could not make new BE bootable"
183211
log "Install complete"
212+
SendInstallLog
184213
return 0
185214
}

0 commit comments

Comments
 (0)