install.sh 3.03 KB
Newer Older
Carlos Remuzzi's avatar
Carlos Remuzzi committed
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
# script basado en https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh

main() {
  # colores
  if which tput >/dev/null 2>&1; then
      ncolors=$(tput colors)
  fi
  if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
    RED="$(tput setaf 1)"
    GREEN="$(tput setaf 2)"
    YELLOW="$(tput setaf 3)"
    BLUE="$(tput setaf 4)"
    BOLD="$(tput bold)"
    NORMAL="$(tput sgr0)"
  else
    RED=""
    GREEN=""
    YELLOW=""
    BLUE=""
    BOLD=""
    NORMAL=""
  fi

  # Habilitacion de exit-on-error despues de colores 
  set -e

  if [ ! -n "$LIBRECAST" ]; then
    LIBRECAST=~/librecast
  fi

  if [ -d "$LIBRECAST" ]; then
    printf "${YELLOW}Ya tienes libreCast instalado.${NORMAL}\n"
    printf "tienes que eliminar $LIBRECAST si quieres re-instalar.\n"
    exit
  fi


  # Control de permisos, para evitar la clonacion del repo con privilegios
  # no deseados
  umask g-w,o-w

  printf "${BLUE}Clonando libreCast...${NORMAL}\n"
  hash git >/dev/null 2>&1 || {
    echo "Error: git no esta instalado"
45
    sudo apt install git
Carlos Remuzzi's avatar
Carlos Remuzzi committed
46
47
  }

48
  env git -c http.sslVerify=false clone https://gitlab.geo.gob.bo/agetic/librecast.git $LIBRECAST || {
Carlos Remuzzi's avatar
Carlos Remuzzi committed
49
50
51
52
    printf "Error: el git clone del repo librecast ha fallado \n"
    exit 1
  }

Carlos Remuzzi's avatar
Carlos Remuzzi committed
53
54
55
56
57
58
59
60
61
62
  hash gst-launch-1.0  >/dev/null 2>&1 || {
    echo "Error: gstreamer no esta instalado"
    sudo apt install gstreamer1.0-tools
  }

  hash pacmd  >/dev/null 2>&1 || {
    echo "Error: pulseaudio no esta instalado"
    sudo apt install pulseaudio-utils
  }

63
64
  hash curl >/dev/null 2>&1 || {
    echo "Error: curl no esta instalado"
Carlos Remuzzi's avatar
Carlos Remuzzi committed
65
    sudo apt install curl
66
67
  }

Carlos Remuzzi's avatar
Carlos Remuzzi committed
68
69
70
71
72
  hash nmcli >/dev/null 2>&1 || {
    echo "Error: nmcli no esta instalado"
    exit 1
  }

Carlos Remuzzi's avatar
Carlos Remuzzi committed
73
  # esto tiene que adaptarse a diferentes distros
Carlos Remuzzi's avatar
Carlos Remuzzi committed
74
75
76
  WIFI_INTERFACE=wlan0
  AP_NAME=libreCast-s0
  AP_PSK=libreCast
77
  USER_NAME=$(whoami)
Carlos Remuzzi's avatar
Carlos Remuzzi committed
78

Carlos Remuzzi's avatar
Carlos Remuzzi committed
79
  if [ -d "$HOME/.local/share/applications/" ];then
80
    cp $HOME/librecast/libreCast.desktop $HOME/.local/share/applications/
81
    sed -i -e "s/USER/$USER_NAME/g" $HOME/.local/share/applications/libreCast.desktop
Carlos Remuzzi's avatar
Carlos Remuzzi committed
82
  fi
Carlos Remuzzi's avatar
Carlos Remuzzi committed
83

Carlos Remuzzi's avatar
Carlos Remuzzi committed
84
85
86
87
88
89
90
91
92
93
  if nmcli con show $AP_NAME > /dev/null 2>&1 ;then
    echo "la conneccion $AP_NAME esta ya instalada"
  else
    echo "creando nueva conneccion $AP_NAME"
    nmcli con add con-name $AP_NAME ifname $WIFI_INTERFACE type wifi ssid $AP_NAME ip4 192.168.12.2/24 gw4 192.168.12.1
    nmcli con modify $AP_NAME ipv4.dns "192.168.26.20"
    nmcli con modify $AP_NAME connection.autoconnect no
    nmcli con modify $AP_NAME wifi-sec.key-mgmt wpa-psk wifi-sec.psk $AP_PSK
    nmcli con modify $AP_NAME wifi-sec.psk libreCast
  fi
94
95
96
97

  # configuracion de la resolucion de pantalla
  # xdpyinfo | awk '/dimensions/{print $2}'

Carlos Remuzzi's avatar
Carlos Remuzzi committed
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  printf "${GREEN}"
  echo '    ___ __              ______           __  '
  echo '   / (_) /_  ________  / ____/___ ______/ /_ '
  echo '  / / / __ \/ ___/ _ \/ /   / __ `/ ___/ __/ '
  echo ' / / / /_/ / /  /  __/ /___/ /_/ (__  ) /_   '
  echo '/_/_/_.___/_/   \___/\____/\__,_/____/\__/   '
  echo ''
  echo '                        ...ha sido instalado!'
  echo ''
  echo ''
  printf "${NORMAL}"
}

main