forked from kercre123/0.11-cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy-create.sh
More file actions
executable file
·155 lines (137 loc) · 4.97 KB
/
deploy-create.sh
File metadata and controls
executable file
·155 lines (137 loc) · 4.97 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/bin/bash
if [[ $1 == "" ]]; then
echo "You must provide an architecture to compile to."
echo "Supported: amd64, arm64"
exit 1
fi
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root. sudo ./setup.sh"
exit 1
fi
UNAME=$(uname -a)
ROOT="/root"
if [[ ${UNAME} == *"Darwin"* ]]; then
if [[ -f /usr/local/Homebrew/bin/brew ]] || [[ -f /opt/Homebrew/bin/brew ]]; then
TARGET="darwin"
ROOT="$HOME"
echo "macOS detected."
if [[ ! -f /usr/local/go/bin/go ]]; then
if [[ -f /usr/local/bin/go ]]; then
mkdir -p /usr/local/go/bin
ln -s /usr/local/bin/go /usr/local/go/bin/go
else
echo "Go was not found. You must download it from https://go.dev/dl/ for your macOS."
exit 1
fi
fi
else
echo "macOS detected, but 'brew' was not found. Install it with the following command and try running setup.sh again:"
echo '/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"'
exit 1
fi
elif [[ -f /usr/bin/apt ]]; then
TARGET="debian"
echo "Debian-based Linux detected."
elif [[ -f /usr/bin/pacman ]]; then
TARGET="arch"
echo "Arch Linux detected."
elif [[ -f /usr/bin/dnf ]]; then
TARGET="fedora"
echo "Fedora/openSUSE detected."
else
echo "This OS is not supported. This script currently supports Linux with either apt, pacman, or dnf."
if [[ ! "$1" == *"--bypass-target-check"* ]]; then
echo "If you would like to get the required packages yourself, you may bypass this by running setup.sh with the --bypass-target-check flag"
echo "The following packages are required (debian apt in this case): wget openssl net-tools libsox-dev libopus-dev make iproute2 xz-utils libopusfile-dev pkg-config gcc curl g++ unzip avahi-daemon git"
exit 1
fi
fi
if [[ "${UNAME}" == *"x86_64"* ]]; then
ARCH="x86_64"
echo "amd64 architecture confirmed."
elif [[ "${UNAME}" == *"aarch64"* ]] || [[ "${UNAME}" == *"arm64"* ]]; then
ARCH="aarch64"
echo "aarch64 architecture confirmed."
elif [[ "${UNAME}" == *"armv7l"* ]]; then
ARCH="armv7l"
echo "armv7l (32-bit) WARN: The Coqui and VOSK bindings are broken for this platform at the moment, so please choose Picovoice when the script asks. wire-pod is designed for 64-bit systems."
STT=""
else
echo "Your CPU architecture not supported. This script currently supports x86_64, aarch64, and armv7l."
exit 1
fi
if [[ ${TARGET} == "debian" ]]; then
apt update -y
apt install -y wget openssl net-tools libsox-dev libopus-dev make iproute2 xz-utils libopusfile-dev pkg-config gcc curl g++ unzip avahi-daemon git libasound2-dev libsodium-dev golang-go
elif [[ ${TARGET} == "arch" ]]; then
pacman -Sy --noconfirm
sudo pacman -S --noconfirm wget openssl net-tools sox opus make iproute2 opusfile curl unzip avahi git libsodium go pkg-config
elif [[ ${TARGET} == "fedora" ]]; then
dnf update
dnf install -y wget openssl net-tools sox opus make opusfile curl unzip avahi git libsodium-devel go
elif [[ ${TARGET} == "darwin" ]]; then
sudo -u $SUDO_USER brew update
sudo -u $SUDO_USER brew install wget pkg-config opus opusfile
fi
echo "getting vosk stuff..."
mkdir -p deploy
cd deploy
if [[ ! -d model ]]; then
mkdir voskModel
cd voskModel
wget https://alphacephei.com/vosk/models/vosk-model-en-us-0.22-lgraph.zip
unzip *.zip
rm *.zip
mv * ../model
cd ../
rm -r voskModel
fi
if [[ ! -d vosk ]]; then
mkdir voskGet
cd voskGet
if [[ $1 == "arm64" ]]; then
wget https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-aarch64-0.3.45.zip
elif [[ $1 == "amd64" ]]; then
wget https://github.com/alphacep/vosk-api/releases/download/v0.3.45/vosk-linux-x86_64-0.3.45.zip
fi
unzip *.zip
rm *.zip
mv * ../vosk
cd ../
rm -r voskGet
fi
if [[ ! -d opus ]]; then
mkdir opus
cd ..
BPREFIX="$(pwd)/deploy/opus"
mkdir opusBuild
cd opusBuild
if [[ $1 == "arm64" ]]; then
PODHOST=aarch64-linux-gnu
else
PODHOST=x86_64-linux-gnu
fi
git clone https://github.com/xiph/opus
cd opus
git checkout 0dc559f060db0d62d95f424e3fd26a5f673b2f6b
./autogen.sh
autoreconf -i
./autogen.sh
./configure --host=${PODHOST} --prefix=$BPREFIX
make -j8
make install
cd ../../deploy
fi
cd ..
echo "Creating server deployment tar..."
rm -f 011-cloud
CC=aarch64-linux-gnu-gcc GCC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=$1 CGO_LDFLAGS="-L$(pwd)/deploy/vosk -L$(pwd)/deploy/opus/lib" CGO_CFLAGS="-I$(pwd)/deploy/vosk -I$(pwd)/deploy/opus/include" go build -tags nolibopusfile -o deploy/011-cloud main.go
cp -r webroot deploy/
cp install.sh deploy/
cp 011-cloud.sh deploy/
cp stttest.pcm deploy/
cp -r intent-data deploy/
cp weather-map.json deploy/
mkdir deploy/secrets
tar -zcvf deploy.tar.gz -C deploy .
#rm -rf deploy