File: install.sh

package info (click to toggle)
liq-contrib 08.11-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 120 kB
  • sloc: sh: 101; makefile: 5
file content (93 lines) | stat: -rwxr-xr-x 2,618 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/sh
set -e

INST_DIR="/usr/local/bin"
DIST="*.in liq-contrib.1 CHANGES COPYING install.sh"
VERSION="08.11"

# Dummy install script for liquidsoap utils.
# Usage: install --install [ /path/to/install/directory ]
# Path to install directory is optional and is 
# $INST_DIR by default.

if [ "$1" = "-h" ] || [ "$1" == "--help" ]; then
  echo "Usage: install.sh --install [ /path/to/install/dir ]"
  echo "Alternate usages:"
  echo "install.sh --clean [ /path/to/install/dir ]: clean previous install"
  echo "install.sh --tarball: prepare a tarball of the scripts"
  echo "install.sh -h|--help: display this message"
  echo ""
  echo "Environement variables: "
  echo "LIQ_BIN: where to find the liquidsoap binary"
  exit 0
elif [ "$1" = "--clean" ]; then
  echo "Cleaning previous install:"
  echo "Removing scripts..."
  if [ "$2" = "" ]; then
    echo "No installation directory provided, using $INST_DIR"
  else
    echo "Using provided install directory: $2"
    INST_DIR="$2"
  fi
find | grep '.in$' | sed -e 's#\.in$##' | while read i; do
  SCRIPT=`basename $i`
  echo "* $SCRIPT"
  rm -f "$INST_DIR/$SCRIPT"
done;
  exit 0
elif [ "$1" = "--tarball" ]; then
  echo "Preparing a tarball at ../liq-contrib-$VERSION.tar.gz..."
  rm -rf liq-contrib-$VERSION
  mkdir liq-contrib-$VERSION
  cp -rf $DIST liq-contrib-$VERSION
  tar cvzf liq-contrib-$VERSION.tar.gz liq-contrib-$VERSION
  mv liq-contrib-$VERSION.tar.gz ..
  rm -rf liq-contrib-$VERSION
  echo "Done !"
  exit 0
elif [ "$1" = "--install" ]; then
  echo "Liquidsoap contributed scripts install starting..."
  if [ "$2" = "" ]; then
    echo "No install path provided, using $INST_DIR"
  else
    echo "Using provided install script: $2"
    INST_DIR=$2
  fi

  echo ""
  # Check for liquidsoap
  echo -n "Checking for liquidsoap... "
  if [ "$LIQ_BIN" = "" ]; then
   LIQ_BIN=`which liquidsoap`
  fi
  if [ "$?" != "0" ]; then
    echo "not found"
    exit 1
  fi
  echo "$LIQ_BIN"

  echo -n "Version found: "
  VER=`$LIQ_BIN --version | head -n 1 | cut -d' ' -f2`
  echo $VER

  # Generating final scripts
  echo "Generating scripts..."
  rm -rf dist
  mkdir dist
  find | grep '.in$' | while read i; do
    SCRIPT=`basename $i | sed -e 's#.in$##'`
    echo "* $SCRIPT"
    cat $i | sed -e "s#@liquidsoap@#$LIQ_BIN#" | sed -e "s#@VERSION@#$VERSION#" > "dist/$SCRIPT"
    chmod +x "dist/$SCRIPT"
  done;

  echo "Installing to $INST_DIR"
  cp -f dist/* "$INST_DIR"
  rm -rf dist
  echo "Finished !"
else
  echo "Wrong argument, or no argument."
  echo "Try install.sh --help to get more informations"
  echo "on how to use this script."
  exit 1
fi