Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit e8f4aa3c50eba0795377d049bb3ceaae3feff7c3 0 parents
@OhMeadhbh authored
0  README
No changes.
149 init.d/larb
@@ -0,0 +1,149 @@
+#! /bin/sh
+### BEGIN INIT INFO
+# Provides: larb
+# Default-Start: 2 3 4 5
+# Default-Stop: 0 1 6
+# Short-Description: starts the appliance user config server
+### END INIT INFO
+
+# Author: Meadhbh Hamrick <OhMeadhbh@gmail.com>
+#
+
+# Do NOT "set -e"
+
+# PATH should only include /usr/* if it runs after the mountnfs.sh script
+PATH=/sbin:/usr/sbin:/bin:/usr/bin
+DESC="appliance personalization server"
+NAME=larb
+DAEMON=/usr/local/bin/node
+DAEMON_ARGS="/opt/larb/server"
+PIDFILE=/var/run/$NAME.pid
+SCRIPTNAME=/etc/init.d/$NAME
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+# Read configuration variable file if it is present
+[ -r /etc/default/$NAME ] && . /etc/default/$NAME
+
+# Load the VERBOSE setting and other rcS variables
+. /lib/init/vars.sh
+
+# Define LSB log_* functions.
+# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
+. /lib/lsb/init-functions
+
+#
+# Function that starts the daemon/service
+#
+do_start()
+{
+ # Return
+ # 0 if daemon has been started
+ # 1 if daemon was already running
+ # 2 if daemon could not be started
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
+ || return 1
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
+ $DAEMON_ARGS \
+ || return 2 &
+ # Add code here, if necessary, that waits for the process to be ready
+ # to handle requests from services started subsequently which depend
+ # on this one. As a last resort, sleep for some time.
+}
+
+#
+# Function that stops the daemon/service
+#
+do_stop()
+{
+ # Return
+ # 0 if daemon has been stopped
+ # 1 if daemon was already stopped
+ # 2 if daemon could not be stopped
+ # other if a failure occurred
+ start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
+ RETVAL="$?"
+ [ "$RETVAL" = 2 ] && return 2
+ # Wait for children to finish too if this is a daemon that forks
+ # and if the daemon is only ever run from this initscript.
+ # If the above conditions are not satisfied then add some other code
+ # that waits for the process to drop all resources that could be
+ # needed by services started subsequently. A last resort is to
+ # sleep for some time.
+ start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
+ [ "$?" = 2 ] && return 2
+ # Many daemons don't delete their pidfiles when they exit.
+ rm -f $PIDFILE
+ return "$RETVAL"
+}
+
+#
+# Function that sends a SIGHUP to the daemon/service
+#
+do_reload() {
+ #
+ # If the daemon can reload its configuration without
+ # restarting (for example, when it is sent a SIGHUP),
+ # then implement that here.
+ #
+ start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
+ return 0
+}
+
+case "$1" in
+ start)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
+ do_start
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ stop)
+ [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
+ 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
+ esac
+ ;;
+ #reload|force-reload)
+ #
+ # If do_reload() is not implemented then leave this commented out
+ # and leave 'force-reload' as an alias for 'restart'.
+ #
+ #log_daemon_msg "Reloading $DESC" "$NAME"
+ #do_reload
+ #log_end_msg $?
+ #;;
+ restart|force-reload)
+ #
+ # If the "reload" option is implemented then remove the
+ # 'force-reload' alias
+ #
+ log_daemon_msg "Restarting $DESC" "$NAME"
+ do_stop
+ case "$?" in
+ 0|1)
+ do_start
+ case "$?" in
+ 0) log_end_msg 0 ;;
+ 1) log_end_msg 1 ;; # Old process is still running
+ *) log_end_msg 1 ;; # Failed to start
+ esac
+ ;;
+ *)
+ # Failed to stop
+ log_end_msg 1
+ ;;
+ esac
+ ;;
+ *)
+ #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
+ echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
+ exit 3
+ ;;
+esac
+
+:
45 larb.conf
@@ -0,0 +1,45 @@
+server {
+ listen 192.168.56.2:2525;
+ server_name helium.l.nodify.us;
+
+ access_log /var/log/nginx/larb.access_log;
+ error_log /var/log/nginx/larb.error_log;
+
+ location /api/ {
+ proxy_pass http://127.0.0.1:2525/;
+ proxy_redirect off;
+
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_max_temp_file_size 0;
+
+ client_max_body_size 10m;
+ client_body_buffer_size 128k;
+
+ proxy_connect_timeout 90;
+ proxy_send_timeout 90;
+ proxy_read_timeout 90;
+
+ proxy_buffer_size 4k;
+ proxy_buffers 4 32k;
+ proxy_busy_buffers_size 64k;
+ proxy_temp_file_write_size 64k;
+ }
+
+ location / {
+ root /opt/larb/static;
+ expires max;
+ }
+
+ error_page 404 /404.html;
+ error_page 500 502 503 504 /50x.html;
+
+ location /404.html {
+ root /opt/larb/static;
+ }
+
+ location /50x.html {
+ root /opt/larb/static;
+ }
+}
67 personalize.sh
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# Personalize the Node.JS Appliance by adding a new user account, generate
+# openssh server keys if they don't exist and creating ~/.ssh/authorized_keys
+MINPARAMS=3
+
+if [ $# -lt $MINPARAMS ]; then
+ echo "%LARB-F-USAGE; Usage is:"
+ echo "; personalize.sh <Full Name> <Login Name> <Password>"
+ echo "; where:"
+ echo "; Full Name - the user's given name"
+ echo "; Login Name - the user's unix login name"
+ echo "; Password - the user's password."
+ exit 1
+fi
+
+FULLNAME=$1
+USERNAME=$2
+PASSWORD=$3
+
+if [ ! -e /etc/ssh/ssh_host_dsa_key ]; then
+ echo "%LARB-I-OPENSSH; Generating new openssh server keys."
+ /usr/sbin/dpkg-reconfigure openssh-server
+fi
+
+echo "%LARB-I-UNIX; Adding Unix account for $USERNAME."
+echo "$PASSWORD
+$PASSWORD
+" | /usr/sbin/adduser --gecos "$FULLNAME" --add_extra_groups $USERNAME
+
+echo "%LARB-I-SAMBA; Adding Samba account for $USERNAME."
+echo "$PASSWORD
+$PASSWORD
+" | /usr/bin/smbpasswd -a -s $USERNAME
+
+if [ ! -e /home/$USERNAME/.ssh ]; then
+ echo "%LARB-I-SSHDIR; Creating user's ~/.ssh directory."
+ mkdir /home/$USERNAME/.ssh
+ chown $USERNAME /home/$USERNAME/.ssh
+ chgrp $USERNAME /home/$USERNAME/.ssh
+ chmod 700 /home/$USERNAME/.ssh
+fi
+
+echo "%LARB-I-LINKING; Adding symbolic links for nile and amazon."
+if [ -L /etc/nginx/sites-enabled/nile.conf ]; then
+ rm /etc/nginx/sites-enabled/nile.conf
+fi
+ln -s /home/$USERNAME/Projects/nile/nile.conf /etc/nginx/sites-enabled/nile.conf
+
+if [ -L /etc/nginx/sites-enabled/amazon.conf ]; then
+ rm /etc/nginx/sites-enabled/amazon.conf
+fi
+ln -s /home/$USERNAME/Projects/amazon/amazon.conf /etc/nginx/sites-enabled/amazon.conf
+
+if [ -L /var/www/amazon ]; then
+ rm /var/www/amazon
+fi
+ln -s /home/$USERNAME/Projects/amazon/static /var/www/amazon
+
+echo "%LARB-I-AUTHKEY; Adding authorized key to user's ~/.ssh/authorized_keys."
+tr -d '\n\r' >> /home/$USERNAME/.ssh/authorized_keys
+chown $USERNAME /home/$USERNAME/.ssh/authorized_keys
+chgrp $USERNAME /home/$USERNAME/.ssh/authorized_keys
+chmod 600 /home/$USERNAME/.ssh/authorized_keys
+
+echo "%LARB-S-W00T; Personalization process completed."
+exit 0
107 server.js
@@ -0,0 +1,107 @@
+// server.js - api implementation for the larb service
+// Copyright (c) 2011-2012 Meadhbh S. Hamrick, All Rights Reserved
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the "Software"),
+// to deal in the Software without restriction, including without limitation
+// the rights to use, copy, modify, merge, publish, distribute, sublicense,
+// and/or sell copies of the Software, and to permit persons to whom the
+// Software is furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+// IN THE SOFTWARE.
+
+var http = require( 'http' );
+var url = require( 'url' );
+var spawn = require( 'child_process' ).spawn;
+
+var host_port = 2525;
+var host_address = '127.0.0.1';
+
+function run_this ( cmd, args, input, failure, success ) {
+ var process = spawn( cmd, args );
+
+ process.on( 'exit', function ( code ) {
+ if( 0 != code ) {
+ failure();
+ } else {
+ success();
+ }
+ } );
+
+ process.stdin.write( input );
+ process.stdin.end();
+}
+
+var app = http.createServer( function ( request, response ) {
+ var body = '';
+ var rb;
+ var rv = {};
+ var url_bits = url.parse( request.url );
+ request.on( 'data', function( chunk ) {
+ body += chunk;
+ } );
+
+ request.on( 'end', function ( ) {
+ if( ( '/config' === url_bits.path ) && ( 'POST' === request.method ) ) {
+ rb = JSON.parse( body );
+ config( finish_request );
+ } else {
+ finish_request( 404 );
+ }
+ } );
+
+ function is_param_valid ( param ) {
+ return( ('string' === typeof param) && (param.length > 0) );
+ }
+
+ function config ( callback ) {
+ if( is_param_valid( rb.username ) && is_param_valid( rb.password ) ) {
+ var cmd = '/opt/larb/personalize.sh';
+ var args = [ rb.fullname, rb.username, rb.password ];
+ var input = rb.public + '\n';
+
+ function success () {
+ rv.success = true;
+ callback( 200 );
+ }
+
+ function failure () {
+ rv.success = false;
+ rv.error = 'personalization process failed';
+ callback( 200 );
+ }
+ run_this( cmd, args, input, failure, success );
+ } else {
+ rv.success = false;
+ rv.error = 'missing required parameter';
+ callback( 200 );
+ }
+ }
+
+ function finish_request ( status ) {
+ var response_text;
+ var content_type;
+
+ if( 200 === status ) {
+ response_text = JSON.stringify( rv );
+ content_type = 'application/json';
+ } else {
+ response_text = 'error ' + status;
+ content_type = 'text/plain';
+ }
+
+ response.writeHead( status, {'Content-Type': content_type} );
+ response.end( response_text );
+ }
+} );
+
+app.listen( host_port, host_address );
7 skel/.bash_logout
@@ -0,0 +1,7 @@
+# ~/.bash_logout: executed by bash(1) when login shell exits.
+
+# when leaving the console clear the screen to increase privacy
+
+if [ "$SHLVL" = 1 ]; then
+ [ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
+fi
99 skel/.bashrc
@@ -0,0 +1,99 @@
+# ~/.bashrc: executed by bash(1) for non-login shells.
+# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
+# for examples
+
+# If not running interactively, don't do anything
+[ -z "$PS1" ] && return
+
+# don't put duplicate lines in the history. See bash(1) for more options
+# don't overwrite GNU Midnight Commander's setting of `ignorespace'.
+export HISTCONTROL=$HISTCONTROL${HISTCONTROL+,}ignoredups
+# ... or force ignoredups and ignorespace
+export HISTCONTROL=ignoreboth
+
+# append to the history file, don't overwrite it
+shopt -s histappend
+
+# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
+
+# check the window size after each command and, if necessary,
+# update the values of LINES and COLUMNS.
+shopt -s checkwinsize
+
+# make less more friendly for non-text input files, see lesspipe(1)
+#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
+
+# set variable identifying the chroot you work in (used in the prompt below)
+if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then
+ debian_chroot=$(cat /etc/debian_chroot)
+fi
+
+# set a fancy prompt (non-color, unless we know we "want" color)
+case "$TERM" in
+ xterm-color) color_prompt=yes;;
+esac
+
+# uncomment for a colored prompt, if the terminal has the capability; turned
+# off by default to not distract the user: the focus in a terminal window
+# should be on the output of commands, not on the prompt
+#force_color_prompt=yes
+
+if [ -n "$force_color_prompt" ]; then
+ if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
+ # We have color support; assume it's compliant with Ecma-48
+ # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
+ # a case would tend to support setf rather than setaf.)
+ color_prompt=yes
+ else
+ color_prompt=
+ fi
+fi
+
+if [ "$color_prompt" = yes ]; then
+ PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
+else
+ PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+fi
+unset color_prompt force_color_prompt
+
+# If this is an xterm set the title to user@host:dir
+case "$TERM" in
+xterm*|rxvt*)
+ PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
+ ;;
+*)
+ ;;
+esac
+
+# Alias definitions.
+# You may want to put all your additions into a separate file like
+# ~/.bash_aliases, instead of adding them here directly.
+# See /usr/share/doc/bash-doc/examples in the bash-doc package.
+
+#if [ -f ~/.bash_aliases ]; then
+# . ~/.bash_aliases
+#fi
+
+# enable color support of ls and also add handy aliases
+if [ -x /usr/bin/dircolors ]; then
+ eval "`dircolors -b`"
+ alias ls='ls --color=auto'
+ #alias dir='dir --color=auto'
+ #alias vdir='vdir --color=auto'
+
+ #alias grep='grep --color=auto'
+ #alias fgrep='fgrep --color=auto'
+ #alias egrep='egrep --color=auto'
+fi
+
+# some more ls aliases
+#alias ll='ls -l'
+#alias la='ls -A'
+#alias l='ls -CF'
+
+# enable programmable completion features (you don't need to enable
+# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
+# sources /etc/bash.bashrc).
+if [ -f /etc/bash_completion ]; then
+ . /etc/bash_completion
+fi
26 skel/.profile
@@ -0,0 +1,26 @@
+# ~/.profile: executed by the command interpreter for login shells.
+# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
+# exists.
+# see /usr/share/doc/bash/examples/startup-files for examples.
+# the files are located in the bash-doc package.
+
+# the default umask is set in /etc/profile; for setting the umask
+# for ssh logins, install and configure the libpam-umask package.
+#umask 022
+
+# if running bash
+if [ -n "$BASH_VERSION" ]; then
+ # include .bashrc if it exists
+ if [ -f "$HOME/.bashrc" ]; then
+ . "$HOME/.bashrc"
+ fi
+fi
+
+# set PATH so it includes user's private bin if it exists
+if [ -d "$HOME/bin" ] ; then
+ PATH="$HOME/bin:$PATH"
+fi
+
+# set NODE_PATH to include the npm modules directory
+export NODE_PATH=`/usr/local/bin/npm -g root`
+
45 skel/Projects/amazon/amazon.conf
@@ -0,0 +1,45 @@
+server {
+ listen 80;
+ server_name amazon.app.nodify.us;
+
+ access_log /var/log/nginx/larb.access_log;
+ error_log /var/log/nginx/larb.error_log;
+
+ location /api/ {
+ proxy_pass http://127.0.0.1:9010/;
+ proxy_redirect off;
+
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_max_temp_file_size 0;
+
+ client_max_body_size 10m;
+ client_body_buffer_size 128k;
+
+ proxy_connect_timeout 90;
+ proxy_send_timeout 90;
+ proxy_read_timeout 90;
+
+ proxy_buffer_size 4k;
+ proxy_buffers 4 32k;
+ proxy_busy_buffers_size 64k;
+ proxy_temp_file_write_size 64k;
+ }
+
+ location / {
+ root /var/www/amazon;
+ expires max;
+ }
+
+ error_page 404 /404.html;
+ error_page 500 502 503 504 /50x.html;
+
+ location /404.html {
+ root /var/www/amazon;
+ }
+
+ location /50x.html {
+ root /var/www/amazon;
+ }
+}
6 skel/Projects/amazon/server.js
@@ -0,0 +1,6 @@
+var http = require( 'http' );
+
+http.createServer( function( request, response ) {
+ response.writeHead( 200, {'Content-Type': 'text/plain'} );
+ response.end( 'amazon ' + (new Date()).toString() );
+} ).listen( 9010, '127.0.0.1' );
17 skel/Projects/amazon/static/400.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>not found</title>
+<style>
+body { font-family: Tahoma, Verdana, Arial, sans-serif; }
+</style>
+</head>
+<body bgcolor="white" text="black">
+<table width="100%" height="100%">
+<tr>
+<td align="center" valign="middle">
+the resource you were looking for was not found.
+</td>
+</tr>
+</table>
+</body>
+</html>
18 skel/Projects/amazon/static/50x.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>The page is temporarily unavailable</title>
+<style>
+body { font-family: Tahoma, Verdana, Arial, sans-serif; }
+</style>
+</head>
+<body bgcolor="white" text="black">
+<table width="100%" height="100%">
+<tr>
+<td align="center" valign="middle">
+The page you are looking for is temporarily unavailable.<br/>
+Please try again later.
+</td>
+</tr>
+</table>
+</body>
+</html>
8 skel/Projects/amazon/static/index.html
@@ -0,0 +1,8 @@
+<html>
+ <head>
+ <title>amazon</title>
+ </head>
+ <body>
+ <p>amazon</p>
+ </body>
+</html>
29 skel/Projects/nile/nile.conf
@@ -0,0 +1,29 @@
+server {
+ listen 80;
+ server_name nile.app.nodify.us;
+
+ access_log /var/log/nginx/larb.access_log;
+ error_log /var/log/nginx/larb.error_log;
+
+ location / {
+ proxy_pass http://127.0.0.1:9000/;
+ proxy_redirect off;
+
+ proxy_set_header Host $host;
+ proxy_set_header X-Real-IP $remote_addr;
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_max_temp_file_size 0;
+
+ client_max_body_size 10m;
+ client_body_buffer_size 128k;
+
+ proxy_connect_timeout 90;
+ proxy_send_timeout 90;
+ proxy_read_timeout 90;
+
+ proxy_buffer_size 4k;
+ proxy_buffers 4 32k;
+ proxy_busy_buffers_size 64k;
+ proxy_temp_file_write_size 64k;
+ }
+}
6 skel/Projects/nile/server.js
@@ -0,0 +1,6 @@
+var http = require( 'http' );
+
+http.createServer( function( request, response ) {
+ response.writeHead( 200, {'Content-Type': 'text/plain'} );
+ response.end( 'nile ' + (new Date()).toString() );
+} ).listen( 9000, '127.0.0.1' );
17 static/400.html
@@ -0,0 +1,17 @@
+<html>
+<head>
+<title>not found</title>
+<style>
+body { font-family: Tahoma, Verdana, Arial, sans-serif; }
+</style>
+</head>
+<body bgcolor="white" text="black">
+<table width="100%" height="100%">
+<tr>
+<td align="center" valign="middle">
+the resource you were looking for was not found.
+</td>
+</tr>
+</table>
+</body>
+</html>
18 static/50x.html
@@ -0,0 +1,18 @@
+<html>
+<head>
+<title>The page is temporarily unavailable</title>
+<style>
+body { font-family: Tahoma, Verdana, Arial, sans-serif; }
+</style>
+</head>
+<body bgcolor="white" text="black">
+<table width="100%" height="100%">
+<tr>
+<td align="center" valign="middle">
+The page you are looking for is temporarily unavailable.<br/>
+Please try again later.
+</td>
+</tr>
+</table>
+</body>
+</html>
BIN  static/favicon.ico
Binary file not shown
BIN  static/img/nodify_logo_small.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
225 static/index.html
@@ -0,0 +1,225 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Nodify.US Configuration</title>
+ <style type="text/css">
+html {
+ overflow-y: scroll;
+}
+
+body {
+ background-color: #DFDFDF;
+ font-family: sans-serif;
+}
+
+#header {
+ background-color: #7F7FEF;
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ height: 88px;
+ min-width: 800px;
+ width: 100%;
+}
+
+#header_logo {
+ position: relative;
+ top: 4px;
+ left: 4px;
+ height: 80px;
+ width: 64px;
+}
+
+#header_title {
+ position: absolute;
+ top: 1px;
+ right: 4px;
+ font-size: 400%;
+ color: #DFDFDF;
+}
+
+#content {
+ position: absolute;
+ top: 89px;
+ left: 4px;
+ padding: 4px;
+ width: 98%;
+}
+
+#footer {
+ width: 100%;
+ background-color: #7F7FEF;
+ position: absolute;
+ bottom: 0px;
+ left: 0px;
+ height: 22px;
+ line-height: 22px;
+ min-width: 800px;
+ text-align: center;
+ color: #DFDFDF;
+ font-size: 75%;
+}
+
+table {
+ width: 100%;
+}
+
+td.keys {
+ width: 175px;
+ background-color: #7F7FEF;
+ text-align: right;
+ color: #DFDFDF;
+ padding: 4px;
+}
+
+td.values {
+ background-color: #7F7FEF;
+ text-align: left;
+ color: #DFDFDF;
+}
+
+td.submit {
+ background-color: #7F7FEF;
+ text-align: center;
+}
+
+td.message {
+ background-color: #BFBFF7;
+ text-align: center;
+}
+
+td.error {
+ background-color: #F7BFBF;
+ text-align: center;
+}
+
+input.text {
+ position: relative;
+ left: 1%;
+ width: 97%;
+}
+
+input.button {
+ position: relative;
+ left: 1%;
+ width: 97%;
+}
+
+textarea {
+ position: relative;
+ left: 1%;
+ width: 97%;
+ height: 80px;
+}
+
+ </style>
+ <script type="text/javascript">
+function submit() {
+ var fullname = document.getElementById( 'fullname' ).value;
+ var username = document.getElementById( 'username' ).value;
+ var pass1 = document.getElementById( 'pass1' ).value;
+ var pass2 = document.getElementById( 'pass2' ).value;
+ var public = document.getElementById('public').value;
+ var payload = {
+ fullname: fullname,
+ username: username,
+ password: pass1,
+ public: public
+ };
+
+ var error = document.getElementById( 'error' );
+ var request;
+
+ if( pass1 === pass2 ) {
+ error.innerHTML = "configuring user account. one sec!";
+ error.className = "message";
+ if( 'undefined' !== typeof XMLHttpRequest ) {
+ request = new XMLHttpRequest();
+ } else {
+ request = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+ request.open( 'POST', '/api/config', true );
+ request.setRequestHeader( 'Content-Type', 'application/json' );
+ request.onreadystatechange = function( oEvent ) {
+ if( request.readyState === 4 ) {
+ if( request.status === 200 ) {
+ if( request.responseText ) {
+ var rb = JSON.parse( request.responseText );
+ if( rb.success ) {
+ error.innerHTML = "user account configured";
+ error.className = "message";
+ } else {
+ error.innerHTML = "error: " + rb.error;
+ error.className = "error";
+ }
+ } else {
+ error.innerHTML = "error: invalid response from server";
+ error.className = "error";
+ }
+ } else {
+ error.innerHTML = "error: (" + request.status + ") " + request.statusText ;
+ error.className = "error";
+ }
+ }
+ };
+ request.send( JSON.stringify( payload ) );
+ } else {
+ error.innerHTML = "passwords don't match. try again.";
+ error.className = "error";
+ }
+}
+ </script>
+ </head>
+ <body>
+ <div id="header">
+ <img id="header_logo" src="./img/nodify_logo_small.png"/>
+ <div id="header_title">node.js dev kickstarter</div>
+ </div>
+ <div id="content">
+ <h1>Success!</h1>
+ <p>
+ If you're reading this, it means you've successfully installed and
+ started the nodify.us node.js dev kickstarter appliance. For security
+ reasons, we don't ship the appliance with a default password; so
+ before you can use the appliance, you need to set the password for
+ the default nodify account.
+ </p>
+
+ <h1>Config</h1>
+ <table>
+ <tr>
+ <td colspan="2" id="error" class="message">enter details of an admin account, then press "submit" to create it.</td>
+ </tr>
+ <tr>
+ <td class="keys">full name</td>
+ <td class="values"><input class="text" id="fullname"/></td>
+ </tr>
+ <tr>
+ <td class="keys">username</td>
+ <td class="values"><input class="text" id="username"/></td>
+ </tr>
+ <tr>
+ <td class="keys">password</td>
+ <td class="values"><input class="text" type="password" id="pass1"/></td>
+ </tr>
+ <tr>
+ <td class="keys">password (again)</td>
+ <td class="values"><input class="text" type="password" id="pass2"/></td>
+ </tr>
+ <tr>
+ <td class="keys">ssh key (optional)</td>
+ <td class="values"><textarea id="public"></textarea></td>
+ </tr>
+ <tr>
+ <td class="submit"><input class="button" type="button" onclick="submit()" value="submit"/></td>
+ <td>&nbsp;</td>
+ </tr>
+ </table>
+
+ <h1>A Few More Details</h1>
+ </div>
+ <div id="footer">
+ <div class="copy">Copyright &copy; 2011-2012 Meadhbh S. Hamrick, All Rights Reserved.</div>
+ </div>
+ </body>
+</html>

0 comments on commit e8f4aa3

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