Skip to content
Browse files

initial commit

  • Loading branch information...
0 parents commit 14685909ec9ef096ebf7e8a4e094bd2463ee6d87 Greg Fitzgerald committed Jul 11, 2010
Showing with 166 additions and 0 deletions.
  1. +16 −0 Makefile
  2. +21 −0 README
  3. +123 −0 bin/osnap
  4. +5 −0 conf/osnap.conf
  5. 0 doc/readme.mkd
  6. +1 −0 version
16 Makefile
@@ -0,0 +1,16 @@
+DESTDIR="/usr/local"
+SYSCONFDIR="/etc"
+VERSION=`cat ${PWD}/version`
+
+all: install
+
+install:
+ install -d -m0755 ${DESTDIR}/sbin
+ install -m0755 bin/osnap ${DESTDIR}/sbin/osnap
+ install -d -m0755 ${DESTDIR}/share/doc/osnap-${VERSION}
+ install -m0644 doc/* ${DESTDIR}/share/doc/osnap-${VERSION}
+ install -m0600 conf/osnap.conf ${SYSCONFDIR}
+uninstall:
+ rm -f ${DESTDIR}/sbin/osnap
+ rm -f ${SYSCONFDIR}/osnap.conf
+ rm -rf ${DESTDIR}/share/doc/osnap-${VERSION}
21 README
@@ -0,0 +1,21 @@
+Usage
+
+ osnap [Options] Action [Implementation]
+
+Action
+
+ usage - Show this usage screen
+ version - Print Version Number
+ build - Defaults to all
+ kernel - Build Kernel Sources
+ world - Build World Sources
+ all - Build both Kernel and World
+ install -
+ kernel - Installs The Kernel
+ sync - Defaults to All
+ ports - Syncs Ports Tree
+ world - Syncs World Sources
+ all - Syncs Both Ports and World
+
+Author
+ Greg Fitzgerald <netzdamon@gmail.com>
123 bin/osnap
@@ -0,0 +1,123 @@
+#!/bin/sh
+# Distributed under the terms of the MIT License.
+# Copyright (c) 2010 Greg Fitzgerald <netzdamon@gmail.com>
+# vim: set sw=4 sts=4 et tw=80 :
+
+CONF_FILE=${CONF_FILE:="/etc/osnap.conf"}
+
+if [[ -e $CONF_FILE ]]; then
+ source $CONF_FILE
+fi
+
+ARCH=${ARCH:=`machine -a`}
+KERNEL=${KERNEL:=GENERIC}
+CVSROOT=${CVSROOT:="anoncvs@anoncvs1.usa.openbsd.org:/cvs"}
+BRANCH=${BRANCH:=`uname -r`}
+MIRROR=${MIRROR:="http://mirror.rit.edu/pub/OpenBSD/"}
+BSDVER=${BSDVER:=`uname -r`}
+
+ACTION="${1}"
+ACTION_CMD="${2}"
+ARGS="${1}:${2}"
+
+error() {
+ echo "* $@"
+}
+
+die() {
+ msg="${1}"
+ if [[ -z "${msg}" ]]; then
+ msg = "Some asshole forget to set a message for die, but something bad happened. Take cover!"
+ fi
+ error "${msg}"
+ exit 1
+}
+
+osnap_usage() {
+ cat "${osnap_path:-$HOME/work/projects/active/osnap}/README" | ${PAGER:-less}
+}
+
+osnap_parse_args() {
+ case "$ARGS" in
+ build:kernel)
+ build_kernel
+ ;;
+ build:world)
+ build_world
+ ;;
+ build:all)
+ build_kernel
+ build_world
+ ;;
+ sync:world)
+ echo "Sync World"
+ ;;
+ sync:ports)
+ echo "Sync Ports"
+ ;;
+ sync:all)
+ echo "Sync All"
+ ;;
+ install:world)
+ build_world
+ ;;
+ install:kernel)
+ install_kernel
+ ;;
+ *)
+ osnap_usage
+ exit 1
+ ;;
+ esac
+}
+
+setup() {
+ if ! [[ -d /usr/src ]]; then
+ mkdir -p /usr/src
+ fi
+
+ if ! [[ -d /usr/obj ]]; then
+ mkdir -p /usr/obj
+ fi
+
+ # Clean obj directory
+ rm -rf /usr/obj/*
+}
+
+build_kernel() {
+ # Rebuild Kernel
+ if [[ -d /usr/src/sys/arch/${ARCH}/conf ]]; then
+ cd /usr/src/sys/arch/${ARCH}/conf
+ /usr/sbin/config ${KERNEL}
+ cd /usr/src/sys/arch/${ARCH}/compile/${KERNEL}
+ make clean && make depend && make
+ else
+ echo "Seems /usr/src/sys/arch/${ARCH}/conf does not exist."
+ echo "You may need to check out the source tree"
+ exit 1
+ fi
+}
+
+install_kernel() {
+ # Install Kernel
+ cd /usr/src/sys/arch/${ARCH}/compile/${KERNEL}
+ make install
+ reboot
+}
+
+install_world() {
+ # Rebuild Binaries
+ cd /usr/src
+
+ if [[ -d ${PWD}/CVS ]]; then
+ make obj
+ cd /usr/src/etc && env DESTDIR=/ make distrib-dirs
+ cd /usr/src
+ make build
+ else
+ echo "Seems /usr/src is not properly checked out."
+ exit 1
+ fi
+}
+
+osnap_parse_args
5 conf/osnap.conf
@@ -0,0 +1,5 @@
+ARCH=""
+KERNEL=""
+CVSROOT=""
+MIRROR=""
+BSDVER=""
0 doc/readme.mkd
No changes.
1 version
@@ -0,0 +1 @@
+0.0.1

0 comments on commit 1468590

Please sign in to comment.
Something went wrong with that request. Please try again.