/useful/trunk-1

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/useful/trunk-1

« back to all changes in this revision

Viewing changes to install.sh

  • Committer: Gustav Hartvigsson
  • Date: 2021-01-13 18:44:02 UTC
  • Revision ID: git-v1:0dbf5fcfbb68944b25dbeeeceb02ac414ac330ad
Inital code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env bash
 
2
 
 
3
##
 
4
# Install script for these scripts.
 
5
##
 
6
 
 
7
ARGS=()
 
8
ARGS="${@}"
 
9
 
 
10
 
 
11
__INSTALL_DIR=$HOME/bin
 
12
__INSTALL_SET=0
 
13
 
 
14
# https://stackoverflow.com/a/246128
 
15
__CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
16
 
 
17
#TODO: Add unistall option..
 
18
function __usage () {
 
19
  echo ""
 
20
  echo "install.sh [options]"
 
21
  echo ""
 
22
  echo "    Install the scripts"
 
23
  echo ""
 
24
  echo " -h"
 
25
  echo " --help                   Display this help message."
 
26
  echo ""
 
27
  echo ""
 
28
  echo " -i"
 
29
  echo " --install                Install the scripts. You have to provide this"
 
30
  echo "                          if you want to install the scripts."
 
31
  echo ""
 
32
  echo " --target <directory>     Directory to install the scripts into."
 
33
  echo "                          Default: \$HOME/bin"
 
34
  echo ""
 
35
  exit 0
 
36
}
 
37
 
 
38
function __parse_args () {
 
39
  
 
40
  while [[ $# -gt 0 ]]
 
41
  do
 
42
    case "${1}" in
 
43
      -i|--install)
 
44
      __INSTALL_SET=1
 
45
      shift
 
46
      ;;
 
47
      -h|--help)
 
48
      __usage
 
49
      shift
 
50
      ;;
 
51
      --target)
 
52
      __INSTALL_DIR="${2}"
 
53
      exit
 
54
      shift
 
55
      ;;
 
56
      *)
 
57
      shift
 
58
      ;;
 
59
      --)
 
60
      shift
 
61
      break
 
62
      ;;
 
63
    esac
 
64
  done
 
65
}
 
66
 
 
67
function __main () {
 
68
  if [[ $__INSTALL_SET == 1 ]]
 
69
  then
 
70
    mkdir -p $__INSTALL_DIR
 
71
    cp $__CWD/scripts/*.sh $__INSTALL_DIR/
 
72
  else
 
73
    echo ""
 
74
    echo "YOU MUST PROVIE -i OR --install FOR IT TO INSTALL THE SCRIPTS."
 
75
    echo "Please see -h or --help for more information."
 
76
    echo ""
 
77
    exit 1
 
78
  fi
 
79
  exit 0
 
80
}
 
81
 
 
82
__parse_args "${@}"
 
83
__main