Wednesday, February 10, 2016

boot ubuntu 11.04 desktop direct into console (text) but switch to GUI whenever you want

I followed this steps to boot directly into console mode... After lofin, the command startx shows the GUI..

taken from: http://askubuntu.com/questions/74645/possible-to-install-ubuntu-desktop-and-then-boot-to-no-gui


 did following
Step 1 First update your repository by running
sudo apt-get update
Step 2 There is some bug in old version of lightdm, so we need to upgrade the same. To do so run,
sudo apt-get install lightdm
Step 3 Now we have to modify grub config. Step 3a Open /etc/default/grub with your faviourite editor and change
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
to
GRUB_CMDLINE_LINUX_DEFAULT="text"
Step 3b Also comment GRUB_HIDDEN_TIMEOUT=0 This line is for unhiding the GRUB menu
Step 4 Now we will upgrade GRUB configuration
sudo update-grub
Step 5 Ubuntu 11.10 Desktop edition use lightdm for GUI. We need to disable the same
sudo update-rc.d -f lightdm remove
Step 6 Now restart your machine.

Monday, February 8, 2016

script to push to Amazon Elastic Beanstalk (EB) using the CLI and Git with downtime (swapping environments)

I wanted to automate pushing to my Elastic Beanstalk Amazon environment...

here is the simple script I came up with:

requirements:
- you should be able to upload a new version already using Git
- have the EB CLI 3.7.2 (Python 3.4.3) configured in the directory where you are running this script

- copy this script into the directory that you are going to upload
- give the script execution permissions
- eb list should have a current environment (depicted with a '*')

#!/bin/bash
set -e
#get the current environment
/usr/local/bin/eb list > temp_environment
temp_environment=$(grep \* temp_environment | cut -f2 -d" ")

echo
echo
echo "detected environment ->$temp_environment<-"
echo "subtitute this environment y/N"

read answer

if [ "$
answer" =  "y" ]; then
        a=1
else
        echo "your answer was $
answer. byee!"
        exit 1
fi

echo "substituting environmet with current version"

echo
echo

sufijo=`date +%a%y%m%d%H%M%S`

ambiente_sin_sufijo=$(echo $temp_environment | cut -d"-" -f1)
sufijo_ambiente=$(echo $temp_environment | cut -d"-" -f2)

dayname=$(echo $sufijo_ambiente | cut -c1-3)
year=$(echo $sufijo_ambiente | cut -c4-5)
mon=$(echo $sufijo_ambiente | cut -c6-7)
day=$(echo $sufijo_ambiente | cut -c8-9)
hour=$(echo $sufijo_ambiente | cut -c10-11)
min=$(echo $sufijo_ambiente | cut -c12-13)
sec=$(echo $sufijo_ambiente | cut -c14-15)

set -x

echo "New version uploaded to EB: `date`" > gitlog.temp
echo ""  >> gitlog.temp
echo "The files that changed since last time are:"   >> gitlog.temp
echo ""   >> gitlog.temp

set -f
git log --name-only --no-color --graph '--pretty=format:%h - %s' --abbrev-commit --since "20$year-$mon-$day $hour:$min:$sec" >> gitlog.temp


ambiente_final="prod"-"$sufijo"

echo "Deploying to: $ambiente_final and then swapping with: $temp_environment"
echo "do you wish to continue? s/N"

read respuesta

if [ "$respuesta" =  "s" ]; then
        a=1
else
        echo "su respuesta fue $respuesta, entonces salimos. chao!"
        exit 1
fi


set -x

eb clone "$temp_environment" -n "$ambiente_final" --timeout 15 || exit 1
eb deploy "$ambiente_final" || exit 1
eb swap "$temp_environment" -n "$ambiente_final" || exit 1
eb use "$ambiente_final" || exit 1

set +x

echo
echo
echo
echo FINISHED !!!
echo
echo
echo "Remember to execute -> eb terminate $temp_environment <-"

mail -s "New version" -r "Auto Uploader<no-reply@mail.com>" myemail@mail.com < gitlog.temp

rm gitlog.temp

send text file contents throught mail in bash mail



turns out it is quite simple:

for example:

mail -s 'Uptime Report' you@mail.com -c copy@mail.com < /tmp/output.txt





taken from: http://www.cyberciti.biz/faq/email-howto-send-text-file-using-unix-appleosx-bsd/