quick-jibri-installer/jigasi.sh

230 lines
7.6 KiB
Bash
Raw Normal View History

2019-07-29 09:24:32 +00:00
#!/bin/bash
2020-04-11 09:51:31 +00:00
# Quick Jigasi Installer - *buntu (LTS) based systems.
# SwITNet Ltd © - 2020, https://switnet.net/
2019-07-29 09:24:32 +00:00
# GPLv3 or later.
##################### Whistlist #######################
# Saves final transcript in translated languages #130 -
# https://github.com/jitsi/jigasi/pull/130
#######################################################
#Check if user is root
if ! [ $(id -u) = 0 ]; then
echo "You need to be root or have sudo privileges!"
exit 0
fi
2019-07-29 09:24:32 +00:00
clear
echo '
########################################################################
Jigasi Transcript addon
########################################################################
by Software, IT & Networks Ltd
'
JIGASI_CONFIG=/etc/jitsi/jigasi/config
GC_API_JSON=/opt/gc-sdk/GCTranscriptAPI.json
DOMAIN=$(ls /etc/prosody/conf.d/ | grep -v localhost | awk -F'.cfg' '{print $1}' | awk '!NF || !seen[$0]++')
MEET_CONF=/etc/jitsi/meet/${DOMAIN}-config.js
JIG_SIP_PROP=/etc/jitsi/jigasi/sip-communicator.properties
2019-07-30 18:57:41 +00:00
DIST=$(lsb_release -sc)
CHECK_GC_REPO=$(apt-cache policy | grep http | grep cloud-sdk | head -n1 | awk '{print $3}' | awk -F '/' '{print $1}')
2019-07-29 09:24:32 +00:00
2019-07-30 18:57:41 +00:00
install_gc_repo() {
if [ "$CHECK_GC_REPO" = "cloud-sdk-$DIST" ]; then
echo "
Google Cloud SDK repository already on the system!
"
else
echo "
Adding Google Cloud SDK repository for latest updates
"
export CLOUD_SDK_REPO="cloud-sdk-$DIST"
echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | sudo tee -a /etc/apt/sources.list.d/google-cloud-sdk.list
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
fi
}
install_gc_repo
2020-04-14 16:49:11 +00:00
apt-get -q2 update
apt-get -y install google-cloud-sdk google-cloud-sdk-app-engine-java
2019-07-29 09:24:32 +00:00
echo "Please select one of the current options:
[1] I want to configure a new project, service account, billing and JSON credentials.
2019-07-29 17:13:41 +00:00
[2] I already have one project configured and already have a JSON key file from Google"
2019-07-29 09:24:32 +00:00
while [[ $SETUP_TYPE != 1 && $SETUP_TYPE != 2 ]]
do
read -p "What option suits your setup?: (1 or 2)"$'\n' -r SETUP_TYPE
if [ $SETUP_TYPE = 1 ]; then
echo "We'll setup a GC Projects from scratch"
elif [ $SETUP_TYPE = 2 ]; then
echo "We'll setup only the proect and JSON key."
fi
done
if [ $SETUP_TYPE = 1 ]; then
### Start of new project configuration - Google SDK
#Setup option 1 - Google Cloud SDK
echo "Once logged on Google Cloud SDK, please create a new project (last option)."
gcloud init
read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME
#Second login - Google Auth Library
echo "Login to Google Auth Library"
gcloud auth application-default login
# Start Google Cloud Configuration - Application Service
GC_MEMBER=transcript
echo "Checking if project exist..."
PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}')
2019-07-31 07:37:12 +00:00
while [ -z $PROJECT_GC_ID ]
2019-07-29 09:24:32 +00:00
do
read -p "Enter the project name you just created for Jigasi Speech-to-Text"$'\n' -r GC_PROJECT_NAME
2019-07-29 17:13:41 +00:00
if [ -z PROJECT_GC_ID ]; then
2019-07-29 09:24:32 +00:00
echo "Please check your project name,
There is no project listed with the provided name: $GC_PROJECT_NAME"
PROJECT_GC_ID=$(gcloud projects list | grep $GC_PROJECT_NAME | awk '{print$3}')
fi
2019-07-29 17:13:41 +00:00
done
2019-07-29 09:24:32 +00:00
echo "Your $GC_PROJECT_NAME ID's project is: $PROJECT_GC_ID"
# Enable Speech2Text
echo "Important: Please enable billing on your project using the following URL:
https://console.developers.google.com/project/$PROJECT_GC_ID/settings"
echo "Checking billing..."
CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)"
while [[ $? -eq 1 ]]
do
CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)"
if [[ $? -eq 1 ]]; then
echo "Seems you haven't enabled billing for this project: $GC_PROJECT_NAME
2019-07-31 07:37:12 +00:00
For that go to: https://console.developers.google.com/project/$PROJECT_GC_ID/settings
"
2019-07-29 09:24:32 +00:00
read -p "Press Enter to continue"
CHECK_BILLING="$(gcloud services enable speech.googleapis.com 2>/dev/null)"
fi
done
echo "Billing account seems setup, continuing..."
gcloud iam service-accounts create $GC_MEMBER
gcloud projects add-iam-policy-binding $GC_PROJECT_NAME \
--member serviceAccount:$GC_MEMBER@$GC_PROJECT_NAME.iam.gserviceaccount.com \
--role roles/editor
echo "Setup credentials:"
echo "Please go and download your valid json key at:
https://console.developers.google.com/apis/credentials?folder=&organizationId=&project=$GC_PROJECT_NAME"
### End of new project configuration - Google SDK
fi
if [ $SETUP_TYPE = 2 ]; then
#Setup option 1 - Google Cloud SDK
echo "Once logged on Google Cloud SDK, please select the project that owns to the JSON key."
gcloud init
2019-07-30 20:16:37 +00:00
echo "Login to Google Auth Library"
gcloud auth application-default login
2019-07-29 09:24:32 +00:00
fi
echo "Setting up JSON key file..."
sleep 2
mkdir /opt/gc-sdk/
cat << KEY_JSON > $GC_API_JSON
#
# Paste below this comment your GC JSON key for the service account:
# $GC_MEMBER@$GC_PROJECT_NAME.iam.gserviceaccount.com
#
2019-07-31 07:37:12 +00:00
# Visit the following URL and create a *Service Account Key*:
# https://console.developers.google.com/apis/credentials?folder=&organizationId=&project=$GC_PROJECT_NAME
2019-07-29 09:24:32 +00:00
# These comment lines will be deleted afterwards.
#
KEY_JSON
chmod 644 $GC_API_JSON
nano $GC_API_JSON
2019-07-31 07:37:12 +00:00
sed -i '/^#/d' $GC_API_JSON
2019-07-29 09:24:32 +00:00
CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)"
while [[ $? -eq 1 ]]
do
CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)"
if [[ $? -eq 1 ]]; then
echo "Check again your JSON file, syntax doesn't seem right"
sleep 2
nano $GC_API_JSON
CHECK_JSON_KEY="$(cat $GC_API_JSON | python -m json.tool 2>/dev/null)"
fi
done
2019-07-29 17:13:41 +00:00
echo "
Great, seems your JSON key syntax is fine.
"
2019-07-30 18:57:41 +00:00
sleep 2
2019-07-29 09:24:32 +00:00
export GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON
2019-07-31 07:37:12 +00:00
echo "Installing Jigasi, your SIP credentials will be asked. (mandatory)"
2020-05-09 02:48:30 +00:00
apt-get -y install jigasi=1.0-235
2019-07-29 09:24:32 +00:00
cat << JIGASI_CONF >> $JIGASI_CONFIG
GOOGLE_APPLICATION_CREDENTIALS=$GC_API_JSON
JIGASI_CONF
echo "Your Google Cloud credentials are at $GC_API_JSON"
echo "Setting up Jigasi transcript with current platform..."
#Connect callcontrol
sed -i "s|// call_control:|call_control:|" $MEET_CONF
2019-07-29 17:34:24 +00:00
sed -i "s|// transcribingEnabled|transcribingEnabled|" $MEET_CONF
sed -i "/transcribingEnabled/ s|false|true|" $MEET_CONF
2019-07-29 09:24:32 +00:00
#siptest2siptest@domain.con
#changed from conference to internal.auth from jibri
sed -i "s|siptest|siptest@internal.auth.$DOMAIN|" $JIG_SIP_PROP
#Enable transcript / disable sip
sed -i "/ENABLE_TRANSCRIPTION/ s|#||" $JIG_SIP_PROP
sed -i "/ENABLE_TRANSCRIPTION/ s|false|true|" $JIG_SIP_PROP
sed -i "/ENABLE_SIP/ s|#||" $JIG_SIP_PROP
sed -i "/ENABLE_SIP/ s|true|false|" $JIG_SIP_PROP
#Transcript format
sed -i "/SAVE_JSON/ s|# ||" $JIG_SIP_PROP
sed -i "/SEND_JSON/ s|# ||" $JIG_SIP_PROP
sed -i "/SAVE_TXT/ s|# ||" $JIG_SIP_PROP
sed -i "/SEND_TXT/ s|# ||" $JIG_SIP_PROP
2019-07-30 18:57:41 +00:00
#sed -i "/SEND_TXT/ s|false|true|" $JIG_SIP_PROP
2019-07-29 09:24:32 +00:00
#Remember to study how to use LE or what's needed #ToDo
sed -i "/ALWAYS_TRUST_MODE_ENABLED/ s|# ||" $JIG_SIP_PROP
#Jigasi credentials
sed -i "/xmpp.acc.USER_ID/ s|# ||" $JIG_SIP_PROP
sed -i "/xmpp.acc.USER_ID/ s|SOME_USER\@SOME_DOMAIN|transcript\@auth.$DOMAIN|" $JIG_SIP_PROP
sed -i "/xmpp.acc.PASS/ s|# ||" $JIG_SIP_PROP
sed -i "/xmpp.acc.PASS/ s|SOME_PASS|jigasi|" $JIG_SIP_PROP
sed -i "/xmpp.acc.ANONYMOUS_AUTH/ s|# ||" $JIG_SIP_PROP
prosodyctl register transcript auth.$DOMAIN jigasi
2020-04-11 09:51:31 +00:00
systemctl restart prosody \
jicofo \
jibri* \
jitsi-videobridge*
2019-07-29 17:13:41 +00:00
echo "
To test, you need to enable subtitles beforehand then invite \
\"jitsi_meet_transcribe\" to the meeting (no quotes).
"
2019-07-29 09:24:32 +00:00
2019-07-29 17:13:41 +00:00
echo "
Full transcript files are available at:
--> /var/lib/jigasi/transcripts/
"
2019-07-29 09:24:32 +00:00
2019-07-29 17:13:41 +00:00
echo "
Happy transcripting!
"
2019-07-29 09:24:32 +00:00
#APP.conference._room.dial("jitsi_meet_transcribe");