-
Notifications
You must be signed in to change notification settings - Fork 0
Building a Cloudsdale Server
Add the user and it's home directory
root@cloudsdale:~# adduser zeeraw
Add .ssh folder to Users and change owner.
root@cloudsdale:~# mkdir /home/zeeraw/.ssh; chown zeeraw:zeeraw /home/zeeraw/.ssh
Add the user to sudoers.
root@cloudsdale:~# usermod -a -G sudo zeeraw
Add your pub_rsa to the .ssh directory on your user
Make so that you require no password for sudo
root@cloudsdale:~# nano /etc/sudoers
and change the line %sudo ALL=(ALL) ALL
to %sudo ALL=(ALL) NOPASSWD: ALL
Fix Perl bug.
Add this to /etc/profile
export LANGUAGE=en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
And then run these commands
root@cloudsdale:~# source /etc/profile; locale-gen en_US.UTF-8; dpkg-reconfigure locales
Install build-essential
root@cloudsdale:~# apt-get install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev \
libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison subversion imagemagick graphicsmagick libmagickcore-dev libmagickwand-dev
Install git
root@cloudsdale:~# apt-get install git-core
Install and configure NTP
root@cloudsdale:~# apt-get install ntp
root@cloudsdale:~# dpkg-reconfigure tzdata
and Navigate into Etc -> UTC
Exit the ssh session and log into the server as your new account.
root@cloudsdale:~# exit
-> ssh zeeraw@[subdomain].cloudsdale.org
Install RVM
zeeraw@cloudsdale:~# curl -L get.rvm.io | sudo bash -s stable
Then add the user to the RVM group
root@cloudsdale:~# usermod -a -G rvm zeeraw
Then install the correct ruby version
zeeraw@cloudsdale:~# rvm install 1.9.3-p125
Set default environment variables for ruby adding this to /etc/profile
:
export RACK_ENV=production
export RAILS_ENV=$RACK_ENV
export RAKE_ENV=$RACK_ENV
navigate to http://mmonit.com/monit/download/ find the latest source
root@cloudsdale:~# wget http://mmonit.com/monit/dist/monit-5.4.tar.gz
root@cloudsdale:~# tar zxvf monit-5.4.tar.gz
root@cloudsdale:~# cd monit-5.4
Install required pam headers
root@cloudsdale:~/monit-5.4# apt-get install libpam0g-dev
Configure
root@cloudsdale:~/monit-5.4# ./configure --enable-optimized
root@cloudsdale:~/monit-5.4# make
root@cloudsdale:~/monit-5.4# make install
Add this to /etc/init.d/monit
:
#!/bin/sh
### BEGIN INIT INFO
# Provides: monit
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: service and resource monitoring daemon
### END INIT INFO
# /etc/init.d/monit start and stop monit daemon monitor process.
# Fredrik Steen, stone@debian.org
# Stefan Alfredsson, alfs@debian.org
PATH=/sbin:/bin:/usr/local/bin:/usr/bin
DAEMON=/usr/local/bin/monit
CONFIG="/etc/monitrc"
DELAY="/etc/monit_delay"
NAME=monit
DESC="daemon monitor"
# Check if DAEMON binary exist
test -f $DAEMON || exit 0
if [ -f "/etc/default/monit" ]; then
. /etc/default/monit
fi
ARGS="-c $CONFIG"
monit_not_configured () {
printf "%b\n" "monit won't be started/stopped\n\tunless it it's configured"
if [ "$1" != "stop" ]
then
printf "%b\n" "\tplease configure monit and then edit /etc/default/monit"
printf "%b\n" "\tand set the \"startup\" variable to 1 in order to allow "
printf "%b\n" "\tmonit to start"
fi
exit 0
}
monit_check_config () {
# Check for emtpy config, probably default configfile.
if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]; then
echo "empty config, please edit $CONFIG."
exit 0
fi
}
monit_check_perms () {
# Check the permission on configfile.
# The permission must not have more than -rwx------ (0700) permissions.
# Skip checking, fix perms instead.
/bin/chmod go-rwx $CONFIG
}
monit_delayed_monitoring () {
if [ -x $DELAY ]; then
$DELAY &
elif [ -f $DELAY ]; then
echo
echo "[WARNING] A delayed start file exists ($DELAY) but it is not executable."
fi
}
monit_check_syntax () {
$DAEMON -t 2>/dev/null >/dev/null
if [ $? -eq 1 ] ; then
echo "Syntax error:"
$DAEMON -t
exit 0
fi
}
monit_checks () {
# Check if startup variable is set to 1, if not we exit.
if [ "$startup" != "1" ]; then
monit_not_configured $1
fi
# Check for emtpy configfile
monit_check_config
# Check permissions of configfile
monit_check_perms
# Check syntax of config file
monit_check_syntax
}
case "$1" in
start)
echo -n "Starting $DESC: "
monit_checks $1
echo -n "$NAME"
start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON > /dev/null 2>&1 -- $ARGS
monit_delayed_monitoring
echo "."
;;
stop)
echo -n "Stopping $DESC: "
#monit_checks $1
echo -n "$NAME"
start-stop-daemon --retry 5 --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
--exec $DAEMON > /dev/null 2>&1
echo "."
;;
restart|force-reload)
$0 stop
$0 start
;;
syntax)
monit_check_syntax
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|force-reload|syntax}" >&2
exit 1
;;
esac
exit 0
Then run
chmod +x /etc/init.d/monit
Add monit to autostart on boot
root@cloudsdale:/etc# update-rc.d -f monit defaults
Clone Monit configs from git
root@template:/etc# git clone git@github.com:IOMUSE/Cloudsdale-Monit.git monit
cd /etc
root@template:/etc# ln -s monit/monitrc
You can now visit monit at:
http://[subdomain].cloudsdale.org:2812/