forked from coolaj86/walnut.js
		
	
		
			
	
	
		
			100 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
		
		
			
		
	
	
			100 lines
		
	
	
		
			2.4 KiB
		
	
	
	
		
			Bash
		
	
	
	
	
	
|  | #!/bin/bash
 | ||
|  | 
 | ||
|  | set -e | ||
|  | set -u | ||
|  | 
 | ||
|  | ############################### | ||
|  | #                             # | ||
|  | # boilerplate for curl / wget # | ||
|  | #                             # | ||
|  | ############################### | ||
|  | 
 | ||
|  | http_get="" | ||
|  | http_opts="" | ||
|  | http_out="" | ||
|  | 
 | ||
|  | detect_http_get() | ||
|  | { | ||
|  |   if type -p curl >/dev/null 2>&1; then | ||
|  |     http_get="curl" | ||
|  |     http_opts="-fsSL" | ||
|  |     http_out="-o" | ||
|  |     #curl -fsSL "$caddy_url" -o "$PREFIX/tmp/$caddy_pkg" | ||
|  |   elif type -p wget >/dev/null 2>&1; then | ||
|  |     http_get="wget" | ||
|  |     http_opts="--quiet" | ||
|  |     http_out="-O" | ||
|  |     #wget --quiet "$caddy_url" -O "$PREFIX/tmp/$caddy_pkg" | ||
|  |   else | ||
|  |     echo "Aborted, could not find curl or wget" | ||
|  |     return 7 | ||
|  |   fi | ||
|  | } | ||
|  | 
 | ||
|  | dap_dl() | ||
|  | { | ||
|  |   $http_get $http_opts $http_out "$2" "$1" | ||
|  | } | ||
|  | 
 | ||
|  | dap_dl_bash() | ||
|  | { | ||
|  |   dap_url=$1 | ||
|  |   #dap_args=$2 | ||
|  |   rm -rf dap-tmp-runner.sh | ||
|  |   $http_get $http_opts $http_out dap-tmp-runner.sh "$dap_url"; bash dap-tmp-runner.sh; rm dap-tmp-runner.sh | ||
|  | } | ||
|  | 
 | ||
|  | detect_http_get | ||
|  | 
 | ||
|  | ############################### | ||
|  | #                             # | ||
|  | # actual script continues...  # | ||
|  | #                             # | ||
|  | ############################### | ||
|  | 
 | ||
|  | install_walnut() | ||
|  | { | ||
|  |   sudo mkdir -p /srv/walnut/{var,etc,packages,node_modules} | ||
|  |   # www-data exists on linux, _www exists on mac OS | ||
|  |   sudo chown -R $(whoami):www-data /srv/walnut || sudo chown -R $(whoami):_www /srv/walnut | ||
|  |   if [ ! -d "/srv/walnut/core/" ]; then | ||
|  |     git clone https://git.daplie.com/Daplie/walnut.js.git /srv/walnut/core | ||
|  |   fi | ||
|  |   pushd /srv/walnut/core | ||
|  |     if [ ! -d "./.git/" ]; then | ||
|  |       echo "'/srv/walnut/core' exists but is not a git repository... not sure what to do here..." | ||
|  |     fi | ||
|  |     git checkout v1 | ||
|  |     git pull | ||
|  |   popd | ||
|  |   rm -rf /srv/walnut/core/node_modules | ||
|  |   ln -sf ../node_modules /srv/walnut/core/node_modules | ||
|  |   /srv/walnut/core/install-helper.sh /srv/walnut | ||
|  |   # Now that the install is finished we need to set the owner to the user that will actually | ||
|  |   # be running the walnut server. | ||
|  |   sudo chown -R www-data:www-data /srv/walnut || sudo chown -R _www:_www /srv/walnut | ||
|  | } | ||
|  | 
 | ||
|  | # Install node | ||
|  | echo "v8.2.1" > /tmp/NODEJS_VER | ||
|  | daplie-install-node-dev | ||
|  | npm install -g npm@4 | ||
|  | 
 | ||
|  | # Install goldilocks | ||
|  | daplie-install-goldilocks | ||
|  | 
 | ||
|  | # Install walnut | ||
|  | install_walnut | ||
|  | 
 | ||
|  | echo "" | ||
|  | echo "You must have some set of domain set up to properly use goldilocks+walnut:" | ||
|  | echo "" | ||
|  | echo "  example.com" | ||
|  | echo "  www.example.com" | ||
|  | echo "  api.example.com" | ||
|  | echo "  assets.example.com" | ||
|  | echo "  cloud.example.com" | ||
|  | echo "  api.cloud.example.com" | ||
|  | echo "" | ||
|  | echo "Check the WALNUT README.md for more info and how to set up /etc/goldilocks/goldilocks.yml" | ||
|  | echo "" |