Shorten CrisisClenup handle
This commit is contained in:
		
							parent
							
								
									189b156854
								
							
						
					
					
						commit
						551d71750a
					
				| @ -10,7 +10,7 @@ ${SOURCE_DIR}/basic.sh | ||||
| 
 | ||||
| # Install applications | ||||
| ${SOURCE_DIR}/ckan.sh | ||||
| # ${SOURCE_DIR}/crisiscleanup.sh | ||||
| # ${SOURCE_DIR}/ccleanup.sh | ||||
| # ${SOURCE_DIR}/cts.sh | ||||
| ${SOURCE_DIR}/gnuhealth.sh | ||||
| ${SOURCE_DIR}/kanboard.sh | ||||
|  | ||||
| @ -56,7 +56,7 @@ | ||||
|             </ul> | ||||
|         </div> | ||||
| 
 | ||||
|         <div class="c" id="crisiscleanup"> | ||||
|         <div class="c" id="ccleanup"> | ||||
|             <h2><a href="#"><img src="img/Crisis_Cleanup.png" alt="Crisis Cleanup" title="Crisis Cleanup">Crisis Cleanup</a></h2> | ||||
|             <p><strong>Mapování krizové pomoci</strong> při odstraňování následků katastrof a koordinaci práce. Jde o majetek, ne o lidi.</p> | ||||
|             <ul> | ||||
|  | ||||
							
								
								
									
										44
									
								
								ccleanup.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										44
									
								
								ccleanup.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,44 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| SOURCE_DIR=$(realpath $(dirname "${0}"))/ccleanup | ||||
| 
 | ||||
| # Check prerequisites | ||||
| docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh | ||||
| docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh | ||||
| docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh | ||||
| 
 | ||||
| # Build Docker container | ||||
| docker build -t ccleanup ${SOURCE_DIR} | ||||
| 
 | ||||
| # Create database | ||||
| export CCLEANUP_PWD=$(head -c 18 /dev/urandom | base64) | ||||
| envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql | ||||
| 
 | ||||
| # Copy existing config files into persistent storage | ||||
| mkdir -p /srv/ccleanup/conf | ||||
| chown 8005:8005 /srv/ccleanup/conf | ||||
| docker run --rm -v /srv/ccleanup/conf:/mnt/conf ccleanup cp -rp /srv/ccleanup/config/. /mnt/conf | ||||
| chown root:root /srv/ccleanup/conf | ||||
| 
 | ||||
| # Configure CrisisCleanup | ||||
| export CCLEANUP_ADMIN_USER="Admin" | ||||
| export CCLEANUP_ADMIN_EMAIL="admin@example.com" | ||||
| export CCLEANUP_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) | ||||
| envsubst <${SOURCE_DIR}/srv/ccleanup/conf/database.yml >/srv/ccleanup/conf/database.yml | ||||
| cp ${SOURCE_DIR}/srv/ccleanup/conf/boot.rb /srv/ccleanup/conf/boot.rb | ||||
| cp ${SOURCE_DIR}/srv/ccleanup/conf/initializers/devise.rb /srv/ccleanup/conf/initializers/devise.rb | ||||
| cp ${SOURCE_DIR}/srv/ccleanup/conf/environments/production.rb /srv/ccleanup/conf/environments/production.rb | ||||
| 
 | ||||
| # Populate database | ||||
| envsubst <${SOURCE_DIR}/srv/ccleanup/db/seeds.rb >/tmp/seeds.rb | ||||
| docker run --rm -h ccleanup --link postgres -v /srv/ccleanup/conf:/srv/ccleanup/config ccleanup rake db:schema:load | ||||
| docker run --rm -h ccleanup --link postgres -v /srv/ccleanup/conf:/srv/ccleanup/config -v /tmp/seeds.rb:/srv/ccleanup/db/seeds.rb ccleanup rake db:seed | ||||
| rm /tmp/seeds.rb | ||||
| 
 | ||||
| # Create CrisisCleanup service | ||||
| cp ${SOURCE_DIR}/etc/init.d/ccleanup /etc/init.d/ccleanup | ||||
| rc-update add ccleanup | ||||
| service ccleanup start | ||||
| 
 | ||||
| # Add application definition | ||||
| spotter-appmgr add-app ccleanup "https://ccleanup.{host}/" "${CCLEANUP_ADMIN_EMAIL}" "${CCLEANUP_ADMIN_PWD}" | ||||
| @ -19,33 +19,33 @@ RUN \ | ||||
|  # Install build dependencies | ||||
|  apk --no-cache add --virtual .deps build-base git libxml2-dev libxslt-dev linux-headers postgresql-dev yarn zlib-dev \ | ||||
|  # Clone CrisisCleanup | ||||
|  && git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/crisiscleanup \ | ||||
|  && git clone --depth 1 https://github.com/CrisisCleanup/crisiscleanup /srv/ccleanup \ | ||||
|  # Hackfix ruby dependency versions | ||||
|  && sed -i 's/2\.2\.5/2.3.6/' /srv/crisiscleanup/Gemfile \ | ||||
|  && sed -i 's/rdoc (4\.2\.0)/rdoc (4.3.0)/' /srv/crisiscleanup/Gemfile.lock \ | ||||
|  && sed -i 's/2\.2\.5/2.3.6/' /srv/ccleanup/Gemfile \ | ||||
|  && sed -i 's/rdoc (4\.2\.0)/rdoc (4.3.0)/' /srv/ccleanup/Gemfile.lock \ | ||||
|  # Install Ruby and NodeJS dependencies | ||||
|  && cd /srv/crisiscleanup \ | ||||
|  && cd /srv/ccleanup \ | ||||
|  && bundle config build.nokogiri --use-system-libraries \ | ||||
|  && bundle install \ | ||||
|  && npm install \ | ||||
|  && yarn \ | ||||
|  # Create CrisisCleanup secret | ||||
|  && echo -e "production:\n  secret_key_base: $(rake secret)" >/srv/crisiscleanup/config/secrets.yml \ | ||||
|  && echo -e "production:\n  secret_key_base: $(rake secret)" >/srv/ccleanup/config/secrets.yml \ | ||||
|  # Generate static resources | ||||
|  && rake assets:precompile \ | ||||
|  # Create OS user | ||||
|  && addgroup -S -g 8005 crisiscleanup \ | ||||
|  && adduser -S -u 8005 -h /srv/crisiscleanup -s /bin/false -g crisiscleanup -G crisiscleanup crisiscleanup \ | ||||
|  && chown -R crisiscleanup:crisiscleanup /srv/crisiscleanup \ | ||||
|  && addgroup -S -g 8005 ccleanup \ | ||||
|  && adduser -S -u 8005 -h /srv/ccleanup -s /bin/false -g ccleanup -G ccleanup ccleanup \ | ||||
|  && chown -R ccleanup:ccleanup /srv/ccleanup \ | ||||
|  # Cleanup | ||||
|  && apk --no-cache del .deps \ | ||||
|  && find /srv/crisiscleanup -name '.git*' -exec rm -rf {} + \ | ||||
|  && find /srv/ccleanup -name '.git*' -exec rm -rf {} + \ | ||||
|  && rm -rf /usr/local/share/.cache \ | ||||
|  && rm -rf /root/.bundle /root/.config /root/.npm | ||||
| 
 | ||||
| VOLUME ["/srv/crisiscleanup/config"] | ||||
| VOLUME ["/srv/ccleanup/config"] | ||||
| EXPOSE 8080 | ||||
| 
 | ||||
| USER crisiscleanup | ||||
| WORKDIR /srv/crisiscleanup | ||||
| USER ccleanup | ||||
| WORKDIR /srv/ccleanup | ||||
| CMD ["rails", "server"] | ||||
							
								
								
									
										6
									
								
								ccleanup/createdb.sql
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								ccleanup/createdb.sql
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| CREATE ROLE ccleanup NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${CCLEANUP_PWD}'; | ||||
| CREATE DATABASE ccleanup; | ||||
| REVOKE ALL ON DATABASE ccleanup FROM public; | ||||
| ALTER DATABASE ccleanup OWNER TO ccleanup; | ||||
| \c ccleanup | ||||
| CREATE EXTENSION hstore; | ||||
| @ -9,18 +9,18 @@ depend() { | ||||
| 
 | ||||
| start() { | ||||
| 	/usr/bin/docker run -d --rm \ | ||||
| 	--name crisiscleanup \ | ||||
| 	-h crisiscleanup \ | ||||
| 	--name ccleanup \ | ||||
| 	-h ccleanup \ | ||||
| 	--link postfix \ | ||||
| 	--link postgres \ | ||||
| 	-v /srv/crisiscleanup/conf:/srv/crisiscleanup/config \ | ||||
| 	crisiscleanup | ||||
| 	-v /srv/ccleanup/conf:/srv/ccleanup/config \ | ||||
| 	ccleanup | ||||
| } | ||||
| 
 | ||||
| start_post() { | ||||
| 	/usr/local/bin/spotter-appmgr update-hosts crisiscleanup | ||||
| 	/usr/local/bin/spotter-appmgr update-hosts ccleanup | ||||
| } | ||||
| 
 | ||||
| stop() { | ||||
| 	/usr/bin/docker stop crisiscleanup | ||||
| 	/usr/bin/docker stop ccleanup | ||||
| } | ||||
							
								
								
									
										8
									
								
								ccleanup/srv/ccleanup/conf/database.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								ccleanup/srv/ccleanup/conf/database.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,8 @@ | ||||
| production: | ||||
|   adapter: postgresql | ||||
|   encoding: unicode | ||||
|   database: ccleanup | ||||
|   pool: 5 | ||||
|   host: postgres | ||||
|   username: ccleanup | ||||
|   password: ${CCLEANUP_PWD} | ||||
| @ -10,7 +10,7 @@ Devise.setup do |config| | ||||
|   # Configure the e-mail address which will be shown in Devise::Mailer, | ||||
|   # note that it will be overwritten if you use your own mailer class | ||||
|   # with default "from" parameter. | ||||
|   config.mailer_sender = 'crisiscleanup@spotter.ngo' | ||||
|   config.mailer_sender = 'ccleanup@spotter.ngo' | ||||
| 
 | ||||
|   # Configure the class responsible to send e-mails. | ||||
|   # config.mailer = 'Devise::Mailer' | ||||
| @ -19,5 +19,5 @@ Legacy::LegacySite.create!([ | ||||
|   {address: "200 Epcot Center Drive", blurred_latitude: 28.3849506927356, blurred_longitude: -81.5443968549352, case_number: "A7", city: "Orlando", claimed_by: 2, legacy_event_id: 1, latitude: 28.383045, longitude: -81.5485919, name: "Timothy Schmidt", phone1: "1234567890", reported_by: 2, requested_at: nil, state: "Florida", status: "Open, unassigned", work_type: "Debris", data: {"email"=>"", "notes"=>"", "habitable"=>"n", "assigned_to"=>"", "electricity"=>"n", "prepared_by"=>"", "rent_or_own"=>"", "unsafe_roof"=>"n", "cross_street"=>"", "status_notes"=>"", "time_to_call"=>"", "older_than_60"=>"n", "other_hazards"=>"", "roof_collapse"=>"n", "special_needs"=>"", "num_trees_down"=>"0", "num_wide_trees"=>"0", "chainsaw_needed"=>"n", "first_responder"=>"n", "autofill_disable"=>"", "electrical_lines"=>"n", "total_volunteers"=>"", "destruction_level"=>"", "meal_location_poc"=>"", "do_not_work_before"=>"", "meal_serving_times"=>"", "structural_problems"=>"n", "required_daily_meals"=>"", "work_without_resident"=>"n", "interior_debris_removal"=>"n", "unsalvageable_structure"=>"n", "heavy_machinary_required"=>"n", "vegitative_debris_removal"=>"n", "hours_worked_per_volunteer"=>"", "initials_of_resident_present"=>"", "nonvegitative_debris_removal"=>"n", "member_of_assessing_organization"=>"n"}, request_date: "2017-09-18", appengine_key: nil, zip_code: "32821", county: "Orange County", phone2: "", work_requested: "", name_metaphone: "TM0 SXMTT", city_metaphone: "ORLNT", county_metaphone: "ORNJ KNT", address_metaphone: " EPKT SNTR TRF", user_id: 2} | ||||
| ]) | ||||
| User.create!([ | ||||
|   {email: "${CRISISCLEANUP_ADMIN_EMAIL}", password: "${CRISISCLEANUP_ADMIN_PWD}", name: "${CRISISCLEANUP_ADMIN_USER}", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, legacy_organization_id: 1, current_sign_in_at: "2016-07-15 03:45:59", last_sign_in_at: "2016-06-08 16:56:37", current_sign_in_ip: "1.1.1.1", last_sign_in_ip: "173.164.56.105", referring_user_id: nil, admin: true, role: nil, mobile: nil, accepted_terms: true, accepted_terms_timestamp: "2017-09-18 20:46:31", title: nil} | ||||
|   {email: "${CCLEANUP_ADMIN_EMAIL}", password: "${CCLEANUP_ADMIN_PWD}", name: "${CCLEANUP_ADMIN_USER}", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 1, legacy_organization_id: 1, current_sign_in_at: "2016-07-15 03:45:59", last_sign_in_at: "2016-06-08 16:56:37", current_sign_in_ip: "1.1.1.1", last_sign_in_ip: "173.164.56.105", referring_user_id: nil, admin: true, role: nil, mobile: nil, accepted_terms: true, accepted_terms_timestamp: "2017-09-18 20:46:31", title: nil} | ||||
| ]) | ||||
| @ -1,44 +0,0 @@ | ||||
| #!/bin/sh | ||||
| 
 | ||||
| SOURCE_DIR=$(realpath $(dirname "${0}"))/crisiscleanup | ||||
| 
 | ||||
| # Check prerequisites | ||||
| docker image ls | grep -q postfix || $(realpath $(dirname "${0}"))/postfix.sh | ||||
| docker image ls | grep -q postgres || $(realpath $(dirname "${0}"))/postgres.sh | ||||
| docker image ls | grep -q ruby || $(realpath $(dirname "${0}"))/ruby.sh | ||||
| 
 | ||||
| # Build Docker container | ||||
| docker build -t crisiscleanup ${SOURCE_DIR} | ||||
| 
 | ||||
| # Create database | ||||
| export CRISISCLEANUP_PWD=$(head -c 18 /dev/urandom | base64) | ||||
| envsubst <${SOURCE_DIR}/createdb.sql | docker exec -i postgres psql | ||||
| 
 | ||||
| # Copy existing config files into persistent storage | ||||
| mkdir -p /srv/crisiscleanup/conf | ||||
| chown 8005:8005 /srv/crisiscleanup/conf | ||||
| docker run --rm -v /srv/crisiscleanup/conf:/mnt/conf crisiscleanup cp -rp /srv/crisiscleanup/config/. /mnt/conf | ||||
| chown root:root /srv/crisiscleanup/conf | ||||
| 
 | ||||
| # Configure CrisisCleanup | ||||
| export CRISISCLEANUP_ADMIN_USER="Admin" | ||||
| export CRISISCLEANUP_ADMIN_EMAIL="admin@example.com" | ||||
| export CRISISCLEANUP_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) | ||||
| envsubst <${SOURCE_DIR}/srv/crisiscleanup/conf/database.yml >/srv/crisiscleanup/conf/database.yml | ||||
| cp ${SOURCE_DIR}/srv/crisiscleanup/conf/boot.rb /srv/crisiscleanup/conf/boot.rb | ||||
| cp ${SOURCE_DIR}/srv/crisiscleanup/conf/initializers/devise.rb /srv/crisiscleanup/conf/initializers/devise.rb | ||||
| cp ${SOURCE_DIR}/srv/crisiscleanup/conf/environments/production.rb /srv/crisiscleanup/conf/environments/production.rb | ||||
| 
 | ||||
| # Populate database | ||||
| envsubst <${SOURCE_DIR}/srv/crisiscleanup/db/seeds.rb >/tmp/seeds.rb | ||||
| docker run --rm -h crisiscleanup --link postgres -v /srv/crisiscleanup/conf:/srv/crisiscleanup/config crisiscleanup rake db:schema:load | ||||
| docker run --rm -h crisiscleanup --link postgres -v /srv/crisiscleanup/conf:/srv/crisiscleanup/config -v /tmp/seeds.rb:/srv/crisiscleanup/db/seeds.rb crisiscleanup rake db:seed | ||||
| rm /tmp/seeds.rb | ||||
| 
 | ||||
| # Create CrisisCleanup service | ||||
| cp ${SOURCE_DIR}/etc/init.d/crisiscleanup /etc/init.d/crisiscleanup | ||||
| rc-update add crisiscleanup | ||||
| service crisiscleanup start | ||||
| 
 | ||||
| # Add application definition | ||||
| spotter-appmgr add-app crisiscleanup "https://crisiscleanup.{host}/" "${CRISISCLEANUP_ADMIN_EMAIL}" "${CRISISCLEANUP_ADMIN_PWD}" | ||||
| @ -1,6 +0,0 @@ | ||||
| CREATE ROLE crisiscleanup NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT LOGIN ENCRYPTED PASSWORD '${CRISISCLEANUP_PWD}'; | ||||
| CREATE DATABASE crisiscleanup; | ||||
| REVOKE ALL ON DATABASE crisiscleanup FROM public; | ||||
| ALTER DATABASE crisiscleanup OWNER TO crisiscleanup; | ||||
| \c crisiscleanup | ||||
| CREATE EXTENSION hstore; | ||||
| @ -1,8 +0,0 @@ | ||||
| production: | ||||
|   adapter: postgresql | ||||
|   encoding: unicode | ||||
|   database: crisiscleanup | ||||
|   pool: 5 | ||||
|   host: postgres | ||||
|   username: crisiscleanup | ||||
|   password: ${CRISISCLEANUP_PWD} | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user