Install the latest git version on Ubuntu

Original Url

 

Steps

  • Install required packages on Ubuntu 14.04
sudo apt-get install software-properties-common
  • Run this command
sudo apt-add-repository ppa:git-core/ppa
sudo apt-get update
sudo apt-get install git
Advertisements

Ubuntu: Start/Stop a program with ‘service’ command

s
# Step
1. Define a servicename
2. Create a script in /etc/init.d/[SERVICE_NAME]

#!/bin/bash
PIDFILE=/var/run/tomcat
DAEMON_START=/vol/users/gatekeeper.tvsw/program/apache-tomcat-7.0.55/bin/startup.sh
DAEMON_SHUTDOWN=/vol/users/gatekeeper.tvsw/program/apache-tomcat-7.0.55/bin/shutdown.sh
DAEMON_ARGS=""
case "$1" in
    start)
        start-stop-daemon --start --quiet  --chuid gatekeeper.tvsw:users --pidfile $PIDFILE --exec $DAEMON_START -- \
            $DAEMON_ARGS || return 2
        ;;
    stop)
#        start-stop-daemon --stop --quiet --oknodo  --retry=0/30/KILL/5  --pidfile $PIDFILE --name jenkins_hq
        start-stop-daemon --start --quiet  --chuid gatekeeper.tvsw:users --pidfile $PIDFILE --exec $DAEMON_SHUTDOWN -- \
            $DAEMON_ARGS || return 2
        #/home/jenkins_hq/program/apache-tomcat-7.0.57/bin/shutdown.sh
        ;;
    *)
        echo "Usage : $0 {start|stop}"
        exit 1
        ;;
esac

“$1” means a first parameter of a script. For example, if you use this command to start a service,

service tomcat start

“$1” is ‘start’

3. Use ‘update-rc.d’ in ordert to register a script you created

sudo update-rc.d tomcat defaults

#Watch out!
1. When you start/stop a service, please use ‘start-stop-daemon’ command with an option ‘–chuid’.
If you do not use that option, a service you registred is runned with root account