2013-07-11 12:14:49 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								/ * 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									NodeBB  -  A  forum  powered  by  node  in  development  by  designcreateplay 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									Copyright  ( C )  2013   DesignCreatePlay  Inc . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									This  program  is  free  software :  you  can  redistribute  it  and / or  modify 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									it  under  the  terms  of  the  GNU  General  Public  License  as  published  by 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									the  Free  Software  Foundation ,  either  version  3  of  the  License ,  or 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									( at  your  option )  any  later  version . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									This  program  is  distributed  in  the  hope  that  it  will  be  useful , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									but  WITHOUT  ANY  WARRANTY ;  without  even  the  implied  warranty  of 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									MERCHANTABILITY  or  FITNESS  FOR  A  PARTICULAR  PURPOSE .   See  the 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									GNU  General  Public  License  for  more  details . 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									You  should  have  received  a  copy  of  the  GNU  General  Public  License 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									along  with  this  program .   If  not ,  see  < http : //www.gnu.org/licenses/>.
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* / 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								( function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									"use strict" ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-23 16:25:16 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									// Configuration setup
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									var  nconf  =  require ( 'nconf' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									nconf . argv ( ) . env ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-05 11:26:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									var  fs  =  require ( 'fs' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-23 15:45:03 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										async  =  require ( 'async' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										winston  =  require ( 'winston' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										pkg  =  require ( './package.json' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-23 15:21:04 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										path  =  require ( 'path' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										meta ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-06-21 13:28:55 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									// Runtime environment
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									global . env  =  process . env . NODE _ENV  ||  'production' ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-23 16:25:16 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									winston . remove ( winston . transports . Console ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston . add ( winston . transports . Console ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										colorize :  true 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-27 14:02:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									winston . add ( winston . transports . File ,  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										filename :  'error.log' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										level :  'error' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-13 14:45:28 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									// TODO: remove once https://github.com/flatiron/winston/issues/280 is fixed
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									winston . err  =  function  ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										winston . error ( err . stack ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-11 12:10:45 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									// Log GNU copyright info along with server info
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston . info ( 'NodeBB v'  +  pkg . version  +  ' Copyright (C) 2013 DesignCreatePlay Inc.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston . info ( 'This program comes with ABSOLUTELY NO WARRANTY.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston . info ( 'This is free software, and you are welcome to redistribute it under certain conditions.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									winston . info ( '' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-10 16:26:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-10-26 10:56:05 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									if  ( ! nconf . get ( 'help' )  &&  ! nconf . get ( 'setup' )  &&  ! nconf . get ( 'upgrade' )  &&  fs . existsSync ( _ _dirname  +  '/config.json' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										// Load server-side configs
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										nconf . file ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											file :  _ _dirname  +  '/config.json' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										meta  =  require ( './src/meta.js' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										nconf . set ( 'url' ,  nconf . get ( 'base_url' )  +  ( nconf . get ( 'use_port' )  ?  ':'  +  nconf . get ( 'port' )  :  '' )  +  nconf . get ( 'relative_path' )  +  '/' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										nconf . set ( 'upload_url' ,  nconf . get ( 'url' )  +  'uploads/' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-19 13:31:04 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										winston . info ( 'Initializing NodeBB v'  +  pkg . version  +  ', on port '  +  nconf . get ( 'port' )  +  ', using Redis store at '  +  nconf . get ( 'redis:host' )  +  ':'  +  nconf . get ( 'redis:port' )  +  '.' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-28 15:24:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										winston . info ( 'NodeBB instance bound to: '  +  ( ( nconf . get ( 'bind_address' )  ===  "0.0.0.0"  ||  ! nconf . get ( 'bind_address' ) )  ?  'Any address (0.0.0.0)'  :  nconf . get ( 'bind_address' ) ) ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-07-16 15:22:59 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										if  ( process . env . NODE _ENV  ===  'development' )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											winston . info ( 'Base Configuration OK.' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-26 17:10:41 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-27 14:02:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										meta . configs . init ( function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											// Initial setup for Redis & Reds
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											var  reds  =  require ( 'reds' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												RDB  =  require ( './src/redis.js' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-27 14:02:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											reds . createClient  =  function  ( )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												return  reds . client  ||  ( reds . client  =  RDB ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											} ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-27 14:02:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											var  templates  =  require ( './public/src/templates.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-20 16:02:25 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												translator  =  require ( './public/src/translator.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												webserver  =  require ( './src/webserver.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 15:59:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												SocketIO  =   require ( 'socket.io' ) . listen ( global . server ,  {  log :  false ,  transports :  [ 'websocket' ,  'xhr-polling' ,  'jsonp-polling' ,  'flashsocket' ] } ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												websockets  =  require ( './src/websockets.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-13 19:16:48 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												posts  =  require ( './src/posts.js' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-28 15:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												plugins  =  require ( './src/plugins' ) ,  // Don't remove this - plugins initializes itself
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												Notifications  =  require ( './src/notifications' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 15:59:08 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											websockets . init ( SocketIO ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											global . templates  =  { } ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-24 14:14:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											global . translator  =  translator ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-20 16:43:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											translator . loadServer ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 14:40:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											var  customTemplates  =  meta . config [ 'theme:templates' ]  ?  path . join ( _ _dirname ,  'node_modules' ,  meta . config [ 'theme:id' ] ,  meta . config [ 'theme:templates' ] )  :  false ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-20 16:02:25 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-20 16:43:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											// todo: replace below with read directory code, derp.
 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											templates . init ( [ 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												'header' ,  'footer' ,  'logout' ,  'outgoing' ,  'admin/header' ,  'admin/footer' ,  'admin/index' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												'emails/reset' ,  'emails/reset_plaintext' ,  'emails/email_confirm' ,  'emails/email_confirm_plaintext' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												'emails/header' ,  'emails/footer' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												'noscript/header' ,  'noscript/home' ,  'noscript/category' ,  'noscript/topic' 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-29 14:40:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											] ,  customTemplates ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											templates . ready ( webserver . init ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-28 15:10:10 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											Notifications . init ( ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-26 10:56:05 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( nconf . get ( 'setup' )  ||  ! fs . existsSync ( _ _dirname  +  '/config.json' ) )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										// New install, ask setup questions
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										if  ( nconf . get ( 'setup' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											winston . info ( 'NodeBB Setup Triggered via Command Line' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											winston . warn ( 'Configuration not found, starting NodeBB setup' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} 
							 
						 
					
						
							
								
									
										
										
										
											2013-05-27 14:02:57 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										var  install  =  require ( './src/install' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-23 13:14:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										winston . info ( 'Welcome to NodeBB!' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( 'This looks like a new installation, so you\'ll have to answer a few questions about your environment before we can proceed.' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( 'Press enter to accept the default setting (shown in brackets).' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-10 16:26:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-18 12:15:29 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
										install . setup ( function  ( err )  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											if  ( err )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
												winston . error ( 'There was a problem completing NodeBB setup: ' ,  err . message ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											}  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-26 10:56:05 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
												winston . info ( 'NodeBB Setup Completed. Run \'node app\' to manually start your NodeBB server.' ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											} 
							 
						 
					
						
							
								
									
										
										
										
											2013-08-23 13:14:36 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-09-17 15:38:50 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
											process . exit ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
									
										
										
										
											2013-10-28 15:24:21 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2013-10-26 10:56:05 -06:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
									}  else  if  ( nconf . get ( 'upgrade' ) )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										nconf . file ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											file :  _ _dirname  +  '/config.json' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										meta  =  require ( './src/meta.js' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										meta . configs . init ( function  ( )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
											require ( './src/upgrade' ) . upgrade ( ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										} ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									}  else /* if (nconf.get('help') */ { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( 'Usage: node app [options] [arguments]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '       [NODE_ENV=development | NODE_ENV=production] node app [--start] [arguments]' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( 'Options:' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '  --help              displays this usage information' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '  --setup             configure your environment and setup NodeBB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '  --upgrade           upgrade NodeBB, first read: github.com/designcreateplay/NodeBB/wiki/Upgrading-NodeBB' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
										winston . info ( '  --start             manually start NodeBB (default when no options are given)' ) ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
									} ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} ( ) ) ;