25 Aralık 2014 Perşembe

Google Drive mount GUI for linux

Google did not develop a good client for its "Google Drive" thats for sure.
I tried several solutions like grive and so on. Grive has its own problems which is not the subject of this post. So I decided to use google-drive-ocamlfuse.
I wtrote a small script using YAD which is basically Zenity on steroids.

Before we can use this GUI kinda script we need to setup google-drive-ocamlfuse. Off we go...

Install google-drive-ocamlfuse for debian derivatives

Open a terminal as your current user (not root) and begin typing:

sudo add-apt-repository ppa:alessandro-strada/ppasudo 
apt-get update 
sudo apt-get install google-drive-ocamlfuse 
google-drive-ocamlfuse

This should open a tab in your default web browser, asking to allow google-drive-ocamlfuse to access your Google Drive. Click "Allow", wait a few seconds for google-drive-ocamlfuse to retrieve the authorization code and you're done.

Actual information can be found here on webupd8.org

Install google-drive-ocamlfuse for suse derivatives

This is working for Suse 13.1, I didnt try other versions but they should work as well.

Open a terminal as your current user (not root) and begin typing:

For suse I started yast out and I created the repository called OPAM with the specific URL "http://download.opensuse.org/repositories/home:/eclipseagent:/opam/openSUSE_13.1/"







And then in terminal
zypper in yad ocaml-findlib gcc ncurses-devel ocaml-ocamldoc libcurl-devel sqlite3-devel ocaml-camlp4-devel fuse-devel zlib-devel
wget http://www.ocamlpro.com/pub/opam_installer.shchmod +x opam_installer.shsh ./opam_installer.sh /usr/local/bin

This will take a while and after it is finisned it will ask you to enter
`opam config env`
command in terminal so do that.

Next you have to initialize opam and install google-drive-ocamlfuse
opam initopam install google-drive-ocamlfuse
So now you have all the packages you need to have.
google-drive-ocamlfuse
This should open a tab in your default web browser, asking to allow google-drive-ocamlfuse to access your Google Drive. Click "Allow", wait a few seconds for google-drive-ocamlfuse to retrieve the authorization code and you're done.

for suse you can use the links below for more information

What does this script do ?

This script provides a mount GUI for google drive. It creates a directory called "googledrive" in your user $HOME and mounts your google drive account to this place. If it is already mounted only MOUNT button is shown and vise versa.

IMPORTANT
All the files are LIVE files so use extreme caution while deleting and updating files because these are the ACTUAL FILES IN YOUR GOOGLE DRIVE. If you delete a file by accident then "say hello to my little friend" or "say goodbye to your file" if you don't have a backup. Always backup. So this is said and done you can not hold me responsible of anything deleted. You have been warned !

Save the below script as gdrive.sh in /usr/bin or whereever you like and "chmod +x gdrive.sh" to make it executable. Now make a shorcut or link in your menu or taskbar of desktop to it.

#!/bin/bash
# google-drive-ocamlfuse mounter HUI
# Cihan Ispanoglu @ 2014

GDRIVE_FOLDER="$HOME/googledrive"
if [ ! -d "$GDRIVE_FOLDER" ]; then
  mkdir -p "$GDRIVE_FOLDER"
fi

YAD=`which yad`
YADKEY=$RANDOM

TITLE=" Google Drive Mount GUI"
HEIGHT=200
WIDTH=400

CURSTATE=""
RET=""
CMD=""

function mount_gdrive()
{

  if grep -qs "google-drive-ocamlfuse" /proc/mounts; then
    CURSTATE="Current State\tAlready mounted\n`grep 'google-drive-ocamlfuse' /proc/mounts | awk '{print $1 ,"\011", $2}' `"
  else
    CURSTATE="Current State\tNot Mounted"
  fi

  $YAD --plug=$YADKEY --tabnum=1 --text "Google Drive" --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" &> res1 &

  if grep -qs "google-drive-ocamlfuse" /proc/mounts; then
    ACTION=`$YAD --center --title "${TITLE}"  --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" --height=$HEIGHT --width=$WIDTH --button="UMOUNT:101" --button="gtk-cancel:1"`
  else
    ACTION=`$YAD --center --title "${TITLE}"  --text "$CURSTATE\n\nMOUNT\tmounts google drive \nUMOUNT\tunmounts google drive" --height=$HEIGHT --width=$WIDTH --button="MOUNT:100" --button="gtk-cancel:1"`
  fi

  RET=$?
  [[ $RET -eq 1 ]] && exit 0

  case $RET in
      100) sleep 1
           google-drive-ocamlfuse $GDRIVE_FOLDER
           sleep 1
           xdg-open $GDRIVE_FOLDER;;           
      101) sleep 1
           fusermount -u $GDRIVE_FOLDER;;
      *) exit 1 ;;        
  esac
}

mount_gdrive
exit

Screenshots of google drive mount GUI for linux





Note: I did not write the "Backup / Policy" and actually took it out now because suse YAD dont have --notebook :) Coming soon...

Thanks for reading.

21 Kasım 2014 Cuma

Linux Apache Server SSL Certificate Generation & Import to another apache server

mkdir /etc/apache2/ssl
cd /etc/apache2/ssl
openssl genrsa -des3 -out server-sec.key 4096
openssl req -new -key server-sec.key -out server.csr
openssl x509 -req -days 365 -in server.csr -signkey server-sec.key -out server.crt
openssl rsa -in server-sec.key -out server.key
ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl

Edit "/etc/apache2/sites-available/default-ssl" with nano or your favourite text editor
Edit the SSLCertificateFile and SSLCertificateKeyFile variables to that they reflect your certificate path

<Virtualhost *:443>
ServerAdmin webmaster@localhost
ServerName localhost
DocumentRoot /var/www-ssl/html/
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/server.crt
SSLCertificateKeyFile /etc/apache2/ssl/server.key

End editing

a2enmod ssl

# restart apache server
/etc/init.d/apache2 restart OR service apache2 restart

Our SSL certificate is ready to be imported to another server

openssl s_client -connect IPOFSERVER:443 | tee ANYNAMEYOULIKE
QUIT

nano ANYNAMEYOULIKE and get rid of the junk. Keep only the text between  -----BEGIN CERTIFICATE----- and  -----END CERTIFICATE-----

# taken from madboa
# Make this a sh file and chmod +x in your certificate folder
# Opensuse => /etc/ssl/certs/
#!/bin/sh
#
# usage: certlink.sh filename [filename ...]

for CERTFILE in $*; do
  # make sure file exists and is a valid cert
  test -f "$CERTFILE" || continue
  HASH=$(openssl x509 -noout -hash -in "$CERTFILE")
  test -n "$HASH" || continue

  # use lowest available iterator for symlink
  for ITER in 0 1 2 3 4 5 6 7 8 9; do
    test -f "${HASH}.${ITER}" && continue
    ln -s "$CERTFILE" "${HASH}.${ITER}"
    test -L "${HASH}.${ITER}" && break
  done
done

After that just enter "./certlink.sh ANYNAMEYOULIKE"

now you have SSL communicatin between those servers.

18 Kasım 2014 Salı

Disable SELINUX and IPTABLES on Centos 7

# DISABLE SELINUX AND IPTABLESsetenforce 0
sed -i.bak "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
systemctl disable iptables.service
systemctl stop iptables.service
systemctl disable firewalld.service
systemctl stop firewalld.service
# /usr/sbin/reboot

Install EL and EPEL repositories for CentOS 7

# EL REPO REPOSITORY
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

# EPEL REPOSITORY
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
rpm -Uvh epel-release-7*.rpm
rm -rf epel-release-7-2.noarch.rpm

Change timezone in centOS 7

ls -la /usr/share/zoneinfo/
cp /usr/share/zoneinfo/YOURTIMEZONE /etc/localtime
timedatectl set-timezone YOURTIMEZONE

Disable smbus and floppy for vmware virtual CentOS 7

echo "blacklist i2c-piix4" >> /etc/modprobe.d/blacklist.conf
echo "blacklist floppy" >> /etc/modprobe.d/blacklist.conf

CentOS 7 change ethernet interface name


sed -i.bak "s/quiet/quiet net.ifnames=0 biosdevname=0/g" /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg