Browse files

gitter chat, updating sysadmin scripts

  • Loading branch information...
Raekye committed Feb 19, 2018
1 parent 4905299 commit eae2580f6b242684ac799f05f5a09db50fff5cd7
@@ -1,4 +1,4 @@
Gamocosm [![Build Status](]( [![Coverage Status](](
Gamocosm [![Build Status](]( [![Coverage Status](]( [![Gitter chat](](

Gamocosm makes it easy to run cloud Minecraft servers.
@@ -24,8 +24,9 @@
<li>Submit an issue on <%= link_to 'GitHub', issues_path %></li>
<li>Reddit PM "raekye" (probably the most reliable way!)</li>
<li>IRC in <code>#gamocosm</code> on <code></code> (<%= link_to 'web chat', irc_path %>) (<%= link_to 'chat history', irc_history_path %>)</li>
<li>I have a terrible track record for IRC, but I set up a proper client now. I'm also on <code></code> (you can direct message me)</li>
<li>IRC in <code>#gamocosm</code> on <a href=""><code></code></a> (<%= link_to 'web chat', irc_path %>) (<%= link_to 'chat history', irc_history_path %>)</li>
<li>I have a terrible track record for IRC, but I set up a proper client now. I'm also on <a href=""><code></code></a> (you can direct message me on either network)</li>
<li><a href="">Gitter chat</a></li>
<div class="col-sm-6">

This file was deleted.

Oops, something went wrong.
@@ -0,0 +1,146 @@

# last updated: 2018 feb 12 for Fedora 27
# not automated:
# - root cron job restart gamocosm and sidekiq
# - root cron job certbot

set -e


# timezone
unlink /etc/localtime
ln -s /usr/share/zoneinfo/America/New_York /etc/localtime

# TODO: swap
# TODO: firewalld cockpit service
# - see
# TODO: rails database unix socket
# TODO: redis unix socket
# TODO: cron
# TODO: vim?
# TODO: still need to modify /etc/hosts ?
# TODO: certbot

dnf -y upgrade

# basic tools
dnf -y install vim tmux git wget
# services
dnf -y install memcached postgresql-server postgresql-contrib redis firewalld certbot
# needed for passenger
dnf -y install gcc gcc-c++ libcurl-devel openssl-devel zlib-devel ruby-devel
# needed for some compilations
dnf -y install redhat-rpm-config
# needed for rvm
dnf -y install patch libffi-devel bison libyaml-devel autoconf readline-devel automake libtool sqlite-devel
# other
dnf -y install nodejs

# databases
# - see
postgresql-setup --initdb --unit postgresql

# append after line
sed -i "/^# TYPE[[:space:]]*DATABASE[[:space:]]*USER[[:space:]]*ADDRESS[[:space:]]*METHOD/a local postgres,gamocosm_development,gamocosm_test,gamocosm_production gamocosm md5" /var/lib/pgsql/data/pg_hba.conf

systemctl enable redis
systemctl start redis

systemctl enable memcached
systemctl start memcached

systemctl enable postgresql
systemctl start postgresql

echo "Run: createuser --createdb --pwprompt --superuser gamocosm"
echo "Run: psql"
echo "Run: \\password postgres"
echo "Run: \\q"
echo "Run: exit"
su - postgres

# no ri (ruby index) or RDoc (ruby documentation)
gem install passenger --no-rdoc --no-ri

# nginx

# only modify 1st line
sed -i "1s/^/user http;\\n/" /opt/nginx/conf/nginx.conf
# umm...
sed -i "$ s/}/include \\/opt\\/nginx\\/sites-enabled\\/\\*.conf;\\n}/" /opt/nginx/conf/nginx.conf
# only modify 1st occurence
sed -i "0,/listen[[:space:]]*80;/{s/80/8000/}" /opt/nginx/conf/nginx.conf

mkdir /opt/nginx/sites-enabled;
mkdir /opt/nginx/sites-available;

wget -O /opt/nginx/sites-available/gamocosm.conf
ln -s /opt/nginx/sites-available/gamocosm.conf /opt/nginx/sites-enabled/gamocosm.conf

wget -O /etc/systemd/system/nginx.service
wget -O /etc/systemd/system/gamocosm-sidekiq.service

adduser -m http

# which better?
#su -l http -c 'gpg2 --keyserver hkp:// --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB'
su -l http -c 'curl -sSL | gpg2 --import -'
su -l http -c 'curl -sSL | bash -s stable'
su -l http -c "rvm install $RUBY_VERSION"
su -l http -c "rvm use --default $RUBY_VERSION"

su -l http -c 'ssh-keygen -t rsa'

mkdir /run/http
chown http:http /run/http

mkdir /var/www
cd /var/www
git clone gamocosm
cd gamocosm
git checkout release
mkdir tmp
touch tmp/restart.txt
chown -R http:http .

sudo -u http gem install bundler
su - http -c "cd $(pwd) && bundle install --deployment"

SECRET_KEY_BASE="$(su - http -c "cd $(pwd) && bundle exec rake secret")"
echo "Generated secret key base $SECRET_KEY_BASE"
DEVISE_SECRET_KEY="$(su - http -c "cd $(pwd) && bundle exec rake secret")"
echo "Generated Devise secret key $DEVISE_SECRET_KEY"
read -p "Please fill in the information in (press any key to continue)... "

sed -i "/SECRET_KEY_BASE/ s/=.*$/=$SECRET_KEY_BASE/"

su - http -c "cd $(pwd) && RAILS_ENV=production ./ --bundler rake db:setup"

su - http -c "cd $(pwd) && RAILS_ENV=production ./ --bundler rake assets:precompile"

#OUTDOORS_IP_ADDRESS=$(ifconfig | grep -m 1 "inet" | awk "{ print \$2 }")
#echo "$OUTDOORS_IP_ADDRESS" >> /etc/hosts

systemctl enable gamocosm-sidekiq
systemctl start gamocosm-sidekiq

systemctl enable nginx
systemctl start nginx

systemctl start firewalld

firewall-cmd --add-service=http
firewall-cmd --add-service=https
firewall-cmd --permanent --add-service=https

# let's encrypt
# - see
certbot certonly

echo "Done!"
@@ -1,4 +1,4 @@
#!/usr/bin/env bash
echo 'In Docker container; patching systemctl.'
if [[ "$1" == "start" ]] && [[ "$2" == "mcsw" ]]; then
cd /home/mcuser/minecraft

0 comments on commit eae2580

Please sign in to comment.