Skip to content

Instantly share code, notes, and snippets.

@rogerleite
Last active May 19, 2023 16:57
Show Gist options
  • Save rogerleite/5927948 to your computer and use it in GitHub Desktop.
Save rogerleite/5927948 to your computer and use it in GitHub Desktop.
Some scripts to install things

Introduction

Some install scripts. Target to work with Ubuntu 12 or greater.

Table of Scripts

#!/bin/bash
# Install Erlang R15B.
#
# Usage: sudo ./erlang-install.sh
#
# By Roger Leite (https://github.com/rogerleite)
#
# Tested on Ubuntu 12.04.2 LTS (cat /etc/issue)
# Created at: 2013-07-04
if [[ $EUID -ne 0 ]]; then
echo "To run this script you need to be root (or use sudo)" 2>&1
exit 1
fi
apt-get -y install build-essential m4 libncurses5-dev libssh-dev unixodbc-dev libgmp3-dev libwxgtk2.8-dev libglu1-mesa-dev fop xsltproc
echo "-> creating sources folder on HOME"
mkdir -p ~/sources/erlang
cd ~/sources/erlang
echo "-> downloading otp_src_R15B.tar.gz"
wget http://www.erlang.org/download/otp_src_R15B.tar.gz
echo "-> extracting source"
tar -xvzf otp_src_R15B.tar.gz
chmod -R 777 otp_src_R15B
cd otp_src_R15B
echo "-> pwd: $(pwd)"
echo "-> ./configure"
./configure
echo "-> make"
make
echo "-> make install"
make install
#!/bin/bash
# Install Heroku's Logplex (https://github.com/heroku/logplex/tree/public-logplex).
#
# Usage: sudo ./logplex-install.sh
#
# By Roger Leite (https://github.com/rogerleite)
#
# Tested on Ubuntu 12.04.2 LTS (cat /etc/issue)
# Created at: 2013-07-04
echo "-> creating apps folder on HOME"
mkdir -p ~/apps
cd ~/apps
echo "-> downloading public-logplex.zip"
wget https://github.com/heroku/logplex/archive/public-logplex.zip
echo "-> unzip"
unzip public-logplex.zip
echo "-> rename to logplex"
mv logplex-public-logplex/ logplex
cd logplex/
echo "-> pwd: $(pwd)"
echo "-> installing dependencies"
./rebar --config public.rebar.config get-deps compile
echo "-> success!"
echo "-> one can start logplex"
echo "-> ./bin/logplex >> logplex.log 2>&1 &"
# create a checklist based on Filirom1 comment
# https://github.com/heroku/logplex/issues/24#issuecomment-12985547
cat <<EOF > checklist.sh
#!/bin/bash
echo "it should be OK"
curl -H"Authorization: Basic \$LOGPLEX_AUTH_KEY" localhost:5000/healthcheck
#echo "create channel"
#curl -XPOST -H"Authorization: Basic \$LOGPLEX_AUTH_KEY" localhost:5000/channels -d{}
#{"channel_id":1,"tokens":[]}
#
#echo "create token"
#curl -XPOST -H"Authorization: Basic \$LOGPLEX_AUTH_key" localhost:5000/channels/1/token -d'{"name": "Romain"}'
#t.ff0d70e5-8c67-46b9-8877-7b2eb9fee937
EOF
chmod +x checklist.sh
echo "-> one can check logplex with:"
echo "-> ./checklist.sh"
#!/bin/bash
echo "-> installing mysql server, client and cia."
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
echo "-> securing mysql server"
sudo mysql_secure_installation
echo "-> going home"
cd ~
echo "-> cloning mysql-provider"
git clone https://github.com/azukiapp/mysql-provider.git
echo "-> installing dependencies"
cd mysql-provider
bundle
echo "-> need to edit rb script with mysql password"
cat lib/mysql_provider.rb
echo "-> preparing mysql-provider log file"
sudo touch /var/log/mysql-provider.log
sudo chown azuki /var/log/mysql-provider.log
echo "-> creating upstart script"
sudo cat <<EOF > /etc/init/mysql-provider.conf
start on (started network-interface
or started network-manager
or started networking)
stop on (stopping network-interface
or stopping network-manager
or stopping networking)
respawn
setuid azuki
setgid azuki
env LOGPLEX_HOST="log.azukiapp.com"
env HEROKU_USERNAME="mysql_addon"
env HEROKU_PASSWORD="cYtNZBNXS9A0ds3z"
env MYSQL_PROVIDER_IP="azuki-provider-qa.cloudapp.net"
chdir /home/azuki/mysql-provider
script
bundle exec thin start -p 8080 >> /var/log/mysql-provider.log 2>&1
end script
EOF
echo "-> done!"
echo "-> WARN don't forget to edit lib/mysql_provider.rb with mysql password"
echo "-> WARN don't forget to edit bind-address to 0.0.0.0 on /etc/mysql/my.cnf"
#!/bin/bash
# Install and run redis using upstart on Ubuntu.
#
# Usage: sudo ./redis-install.sh
#
# By Roger Leite (https://github.com/rogerleite)
#
# Tested on Ubuntu 12.04.2 LTS (cat /etc/issue)
# Created at: 2013-07-04
#
# Script based on gists: (thanks Benny and Thomas!)
#
# https://gist.github.com/bdotdub/714533
# from Benny Wong (https://github.com/bdotdub)
#
# https://gist.github.com/twoolie/4617553
# from Thomas Woolford (https://github.com/twoolie)
if [[ $EUID -ne 0 ]]; then
echo "To run this script you need to be root (or use sudo)" 2>&1
exit 1
fi
echo "-> apt-get install redis-server"
apt-get install redis-server
echo "-> stopping redis-server process"
/etc/init.d/redis-server stop
echo "-> disable redis-server from init.d"
update-rc.d -f redis-server disable
echo "-> remove redis-server from init.d"
update-rc.d -f redis-server remove
echo "-> writing /etc/init/redis-server.conf"
cat <<EOF > /etc/init/redis-server.conf
description "Redis Server"
author "Thomas Woolford <[email protected]>"
# run when the local FS becomes available
start on local-filesystems
stop on shutdown
# The default redis conf has `daemonize = yes` and will naiively fork itself.
expect fork
# Respawn unless redis dies 10 times in 5 seconds
respawn
respawn limit 10 5
env NAME=redis
# start a default instance
instance \$NAME
# run redis as the correct user
setuid redis
setgid redis
# run redis with the correct config file for this instance
exec /usr/bin/redis-server /etc/redis/\${NAME}.conf
EOF
#echo "-> changing daemonize to no on /etc/redis/redis.conf"
#sed -i "s/^daemonize.*/daemonize no/" /etc/redis/redis.conf
echo "-> starting redis-server service"
service redis-server start
echo "-> success!"
cat <<EOF
-> one can check log
tail -f /var/log/redis/redis-server.log
-> commands to control your redis-server
sudo start redis-server [ name=redis ]
sudo restart redis-server [ name=redis ]
sudo status redis-server [ name=redis ]
sudo stop redis-server [ name=redis ]
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment