modified screenrc

This commit is contained in:
Martin Donnelly 2016-08-15 10:28:49 +01:00
parent 3864c47b09
commit 0222323a4c
2 changed files with 268 additions and 2 deletions

264
scripts/mdot_install.sh Normal file
View File

@ -0,0 +1,264 @@
#!/bin/bash
GIT_SERVER="http://gitlab.silvrtree.co.uk/martind2000/mdot_mqtt.git"
GIT_FRONTEND="http://gitlab.silvrtree.co.uk/martind2000/mdot_server.git"
NVM="$HOME/.nvm"
NVM_VERSION="6.3.0"
DEV="$HOME/dev"
LIVE="$HOME/live"
STAGING="$HOME/staging"
SERVER="mdot_mqtt"
FRONT="mdot_server"
SWAP="/swapfile"
NGINXFILE='mdot';
PKG_MANAGER=$( command -v yum || command -v apt-get ) || echo "Neither yum nor apt-get found"
PKG_DEVICE=$(basename $PKG_MANAGER)
pidof systemd && SYSTEMDCALL=1 || SYSTEMDCALL=0
UPDATE=no
DATABASE=no
NGINX=no
RED=`tput setaf 1`
GREEN=`tput setaf 2`
YELLOW=`tput setaf 3`
PURPLE=`tput setaf 5`
RESET=`tput sgr0`
fancy_echo() {
local fmt="$1"; shift
# shellcheck disable=SC2059
printf "\n$fmt\n" "$@"
}
for i in "$@"
do
case $i in
-u|--update)
UPDATE=YES
shift # past argument=value
;;
-d|--database)
DATABASE=YES
shift # past argument=value
;;
-n|--nginx)
NGINX=YES
shift # past argument=value
;;
-i|--install)
UPDATE=YES
NGINX=YES
DATABASE=YES
shift # past argument=value
;;
--default)
DEFAULT=YES
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
fancy_echo "${YELLOW}Installing mDot Console Server ...${RESET}"
## Update initial packages
read -s -p "Enter Password for sudo: " sudoPW
fancy_echo "${RED}Cleaning...${RESET}"
if [ ! -d "$DEV" ]; then
mkdir -p $DEV
fi
if [ ! -d "$LIVE" ]; then
mkdir -p $LIVE
fi
if [ ! -d "$STAGING" ]; then
rm -rf $STAGING
mkdir -p $STAGING
else
mkdir -p $STAGING
fi
if [[ $UPDATE = "YES" ]]; then
fancy_echo "${PURPLE}Updating system packages${RESET}"
if [ $(basename $PKG_MANAGER) = "yum" ]; then
echo $sudoPW | sudo -S yum --assumeyes upgrade
echo $sudoPW | sudo -S yum --assumeyes install deltarpm psmisc
echo $sudoPW | sudo -S yum --assumeyes install epel-release git make automake gcc gcc-c++ kernel-devel nginx htop screen wget curl postgresql postgresql-server postgresql-contrib
else
echo $sudoPW | sudo -S apt-get -y -q --force-yes update
echo $sudoPW | sudo -S apt-get -y -q --force-yes upgrade
echo $sudoPW | sudo -S apt-get --assume-yes install build-essential git nginx htop screen wget curl postgresql postgresql-contrib
fi
fi
# set up and install swap file
if [[ ! -f "$SWAP" ]]; then
fancy_echo "${YELLOW}Setting up swapfile...${RESET}"
echo $sudoPW | sudo -S fallocate -l 1G $SWAP
echo $sudoPW | sudo -S chmod 600 $SWAP
echo $sudoPW | sudo -S mkswap $SWAP
echo $sudoPW | sudo -S swapon $SWAP
fi
# setup node and npm
if [ ! -d "$NVM" ]; then
fancy_echo "${YELLOW}Installing Node...${RESET}"
# Will enter here if $DIRECTORY exists, even if it contains spaces
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash
export NVM_DIR=$NVM
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
source $HOME/.bashrc
source $NVM/nvm.sh
nvm install $NVM_VERSION
fi
# get source and build
# Install global packages.
npm set progress=false
if [[ $UPDATE = "YES" ]]; then
fancy_echo "${YELLOW}Installing Node Global Packages...${RESET}"
npm install -g gulp bower pm2@latest npm-check npm-install-missing ember-cli phantomjs-prebuilt
pm2 update
fi
pm2 completion install
NPM_PATH=$(which npm)
echo $sudoPW | sudo -S su -c "env PATH=$PATH:${NPM_PATH%/npm} pm2 startup linux -u $USER --hp $HOME"
cd $DEV
# Get latest version of smartoffice Admin Server
if [ ! -d "$DEV/$FRONT/.git" ]; then
git clone $GIT_FRONTEND
else
cd $DEV/$FRONT
git pull origin master
fi
if [ ! -d "$DEV/$SERVER/.git" ]; then
git clone $GIT_SERVER
else
cd $DEV/$SERVER
git pull origin master
fi
cd $DEV/$FRONT
npm install . && npm-install-missing
bower install
cd $DEV/$SERVER
npm install . && npm-install-missing
bower install
# gulp default
# rsync -uav --exclude .git $DEV/$FRONT/ $STAGING
# fancy_echo "${YELLOW}Copying files to LIVE...${RESET}"
# rsync -uav --exclude .git $STAGING/ $LIVE
npm set progress=true
if [[ $DATABASE = "YES" ]]; then
fancy_echo "${PURPLE}Setting up Database server...${RESET}"
if [ $(basename $PKG_MANAGER) = "yum" ]; then
PGHOME=/var/lib/pgsql
if [ ! -d "$PGHOME" ]; then
PGHOME=/var/lib/pgsql92
fi
echo $sudoPW | sudo -S rsync -vua `echo $DEV/$SERVER/pg_hba.conf` `echo $PGHOME/data`;
echo $sudoPW | sudo -S chown postgres:postgres `echo $PGHOME/data/pg_hba.conf`
# if [ -e "/var/lib/pgsql9/data/pg_hba.conf" ]; then
if sudo -u postgres test -f "/var/lib/pgsql9/data/pg_hba.conf"; then
echo "${RED}Other...${RESET}"
echo $sudoPW | sudo -s cp `echo $DEV/$SERVER/pg_hba.conf` /var/lib/pgsql9/data/pg_hba.conf
fi
if [ $SYSTEMDCALL -eq 1 ]; then
echo $sudoPW | sudo -S systemctl enable postgresql
sudo -S postgresql-setup initdb
else
echo $sudoPW | sudo -S service postgresql initdb
echo $sudoPW | sudo -S service postgresql restart
fi
else
PGHOME=/var/lib/postgresql
echo $sudoPW | sudo -S rsync -vua `echo $DEV/$SERVER/pg_hba.conf` /etc/postgresql/9.3/main/pg_hba.conf;
echo $sudoPW | sudo -S service postgresql restart
fi
cd $DEV/$SERVER
node dbconfig.js
fi
# Configure nginx
if [[ $NGINX = "YES" ]]; then
fancy_echo "${PURPLE}Setting up NGinx...${RESET}"
echo $sudoPW | sudo -S fuser -k 80/tcp
echo $sudoPW | sudo -S cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.$(date "+%b_%d_%Y_%H.%M.%S")
if [ $(basename $PKG_MANAGER) = "yum" ]; then
if [ $SYSTEMDCALL -eq 1 ]; then
echo $sudoPW | sudo -S systemctl start nginx
else
echo $sudoPW | sudo -S service nginx start
fi
wget https://dl.dropboxusercontent.com/u/233909/smartoffice/$NGINXFILE.nginx -O $HOME/$NGINXFILE.nginx
echo $sudoPW | sudo -S cp $HOME/$NGINXFILE.nginx /etc/nginx/conf.d/$NGINXFILE.conf
if [ -f "/etc/nginx/conf.d/virtual.conf" ]; then
echo $sudoPW | sudo -S mv /etc/nginx/conf.d/virtual.conf /etc/nginx
fi
if [ -d "/var/cache/nginx/proxy" ]; then
echo $sudoPW | sudo -S mkdir -p /var/cache/nginx/proxy
fi
if [ $SYSTEMDCALL -eq 1 ]; then
echo $sudoPW | sudo -S systemctl restart nginx
else
echo $sudoPW | sudo -S service nginx restart
fi
else
echo $sudoPW | sudo -S wget https://dl.dropboxusercontent.com/u/233909/smartoffice/$NGINXFILE.nginx -O /etc/nginx/sites-available/$NGINXFILE.conf && sudo ln -s /etc/nginx/sites-available/$NGINXFILE.conf /etc/nginx/sites-enabled/$NGINXFILE.conf
echo $sudoPW | sudo -S rm /etc/nginx/sites-enabled/default
echo $sudoPW | sudo -S /etc/init.d/nginx restart
fi
fi

View File

@ -1,12 +1,14 @@
altscreen on
defbce on
deflogin on
vbell off
vbell_msg ""
bell_msg "!!! Ding !!!"
termcapinfo xterm-255color|xterm-color|screen-256color ti@:te@
terminfo xterm-255color|xterm-color|screen-256color ti@:te@
termcapinfo xterm|xterms|xs|rxvt ti@:te@
terminfo xterm|xterms|xs|rxvt ti@:te@:
term screen-256color
terminfo rxvt-unicode 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'