From e0bcfa5752c235713fae4a29bb96da715e2512a5 Mon Sep 17 00:00:00 2001 From: pluja Date: Sat, 26 Aug 2023 16:40:30 +0200 Subject: [PATCH] add setup script --- get-whishper.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++++++ setup-linux.sh | 33 ----------------------- 2 files changed, 71 insertions(+), 33 deletions(-) create mode 100644 get-whishper.sh delete mode 100644 setup-linux.sh diff --git a/get-whishper.sh b/get-whishper.sh new file mode 100644 index 0000000..433c256 --- /dev/null +++ b/get-whishper.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +# Check if docker is installed +if ! [ -x "$(command -v docker)" ]; then + echo "Docker is not installed. Please install docker first." + echo "Run official docker installation script? (y/n)" + echo "----> Check out the script: https://get.docker.com" + echo "----> I will run: 'curl -fsSL https://get.docker.com | sudo sh'" + read answer + if [ "$answer" != "${answer#[Yy]}" ] ;then + echo "Running official docker installation script" + curl -fsSL https://get.docker.com | sudo sh + else + echo "Aborting installation" + exit 1 + fi + exit 1 +fi + +# Ask if user wants to get everything in the current directory or in a new directory +echo "Do you want to set up everything in the current directory? (y/n)" +read answer +if [ "$answer" != "${answer#[Yy]}" ] ;then + echo "Setting up everything in the current directory" +else + echo "Enter the name of the directory where you want to set up everything: " + read directory + echo "----> Setting up everything in the $directory directory" + mkdir $directory + cd $directory +fi + +echo "Getting the docker-compose.yml file from Github" +curl -o docker-compose.yml https://raw.githubusercontent.com/pluja/whishper/main/docker-compose.yml + +# Copy env.example to .env +# check if .env exists +if [ -f .env ]; then + echo ".env file already exists" + echo "Do you want to overwrite it? (y/n)" + read answer + if [ "$answer" != "${answer#[Yy]}" ] ;then + echo "Copying env.example to .env" + cp env.example .env + fi +else + echo "Getting the default .env file from Github" + curl -o .env https://raw.githubusercontent.com/pluja/whishper/main/example.env +fi + +# Create necessary directories for libretranslate +echo "Creating necessary directories for libretranslate" +sudo mkdir -p ./whishper_data/libretranslate/{data,cache} + +# This permissions are for libretranslate docker container +echo "Setting permissions for libretranslate" +sudo chown -R 1032:1032 ./whishper_data/libretranslate + +echo "Do you want to pull and build docker images? (y/n)" +read answer +if [ "$answer" != "${answer#[Yy]}" ] ;then + echo "Pulling and building docker images" + sudo docker compose pull +fi + +echo "Do you want to start the containers? (y/n)" +read answer +if [ "$answer" != "${answer#[Yy]}" ] ;then + echo "Starting whishper..." + sudo docker compose up -d +fi \ No newline at end of file diff --git a/setup-linux.sh b/setup-linux.sh deleted file mode 100644 index 401eb29..0000000 --- a/setup-linux.sh +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash - -# Copy env.example to .env -# check if .env exists -if [ -f .env ]; then - echo ".env file exists" - echo "Do you want to overwrite it? (y/n)" - read answer - if [ "$answer" != "${answer#[Yy]}" ] ;then - echo "Copying env.example to .env" - cp env.example .env - fi -else - echo ".env file does not exist" - echo "Copying env.example to .env" - cp env.example .env -fi - -# Create necessary directories for libretranslate -echo "Creating necessary directories for libretranslate" -sudo mkdir -p ./whishper_data/libretranslate/{data,cache} 2&1> /dev/null - -# This permissions are for libretranslate docker container -echo "Setting permissions for libretranslate" -sudo chown -R 1032:1032 ./whishper_data/libretranslate 2&1> /dev/null - -echo "Do you want to pull and build docker images? (y/n)" -read answer -if [ "$answer" != "${answer#[Yy]}" ] ;then - echo "Pulling and building docker images" - docker compose pull - docker compose build -fi \ No newline at end of file