Skip to content

Instantly share code, notes, and snippets.

@msoutopico
Last active April 22, 2020 18:49
Show Gist options
  • Save msoutopico/28609aa7f11daabcab0e56666d06576f to your computer and use it in GitHub Desktop.
Save msoutopico/28609aa7f11daabcab0e56666d06576f to your computer and use it in GitHub Desktop.
Bash script to install and customize OmegaT on Linux
#!/bin/bash
# @author: Adrien Mathot
# Script to install OmegaT and then put the PISA 2021 + PIAAC customization atop it
#Changelog
#v1.5 26/08/2019 Have it download the VER zip files + checking if OMT is installed or not before downloading it
#v1.4 22/05/2019 Tweaks for Ubuntu 19.04
#v1.3 25/04/2019 Update to OMT 4.2
#v1.2 29/03/2019 Update for scripts in the /scripts folder
#v1.1 18/03/2019 Change of some paths on cat.capstan.be
#v1.0 22/02/2019 First version
## How to use it ##
## 1. Download the omtlinux_installer.sh to anywhere in your system
## 2. Run it as:
#~$ sudo bash omtlinux_installer.sh
echo "This script will install OmegaT and install the PISA 2021 customiser"
#Create a temporary folder in /home/, .capstan folder will contain the config
mkdir -p /home/$USER/.capstan/tmp
cd /home/$USER/.capstan/tmp
#check if OmegaT is already installed or not skipping the installation if it is the case
#Taken from OmegaT install script
OMTVERSION="OmegaT_4.2.0"
# check whether /opt/omegat/<OmegaT version> exists
# exit if it does
if [ -d /opt/omegat/$OMTVERSION ]
then
echo "OmegaT is already installed"
else
#This is where the part taken for the OMT installer ends
#Download OmegaT
echo "Downloading and installing OmegaT"
arch=`uname -m` #detect if computer is 32 or 64 bits
if [ ${arch} == "x86_64" ]
then
# 64-bit
# 4.1.5_03
##wget -O omegat.tar.bz2 "https://downloads.sourceforge.net/project/omegat/OmegaT%20-%20Latest/OmegaT%204.1.5%20update%203/OmegaT_4.1.5_03_Beta_Linux_64.tar.bz2?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fomegat%2Ffiles%2FOmegaT%2520-%2520Latest%2FOmegaT%25204.1.5%2520update%25203%2FOmegaT_4.1.5_03_Beta_Linux_64.tar.bz2%2Fdownload&ts=1550831199"
# 4.1.5_04
wget -O omegat.tar.bz2 "http://sourceforge.net/projects/omegat/files/OmegaT%20-%20Latest/OmegaT%204.2.0/OmegaT_4.2.0_Beta_Linux_64.tar.bz2/download"
else
# 32-bit
# 4.1.5_03
##wget -O omegat.tar.bz2 "https://downloads.sourceforge.net/project/omegat/OmegaT%20-%20Latest/OmegaT%204.1.5%20update%203/OmegaT_4.1.5_03_Beta_Linux.tar.bz2?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fomegat%2Ffiles%2FOmegaT%2520-%2520Latest%2FOmegaT%25204.1.5%2520update%25203%2FOmegaT_4.1.5_03_Beta_Linux.tar.bz2%2Fdownload&ts=1550831271"
# 4.1.5_04
wget -O omegat.tar.bz2 "http://sourceforge.net/projects/omegat/files/OmegaT%20-%20Latest/OmegaT%204.2.0/OmegaT_4.2.0_Beta_Linux.tar.bz2/download"
fi
#extract OmegaT archive and cd to the extracted folder
echo "Extracting OmegaT"
tar -jxf omegat.tar.bz2
cd OmegaT*
#Run omegat installer
echo "Installing OmegaT"
bash linux-install.sh
cd ../
fi
#Download the customization files
echo "Downloading the customization files"
wget -nH -r -q --no-parent --cut-dirs=2 https://cat.capstan.be/OmegaT/manual/config.zip #config files
wget -nH -r -q --no-parent --cut-dirs=2 https://cat.capstan.be/OmegaT/manual/plugins.zip #scripts
wget -nH -r -q --no-parent --cut-dirs=2 https://cat.capstan.be/OmegaT/manual/scripts.zip #filters
echo "Extracting customization files"
mkdir config plugins scripts
unzip config.zip -d config/
unzip plugins.zip -d plugins/
unzip scripts.zip -d scripts/
echo "Applying the customization"
#move everything to its right place where they should be
cp -r config ../config
cp -r scripts ../
cp -r plugins ../config/plugins
#copy Vanilla scripts to custom scripts folder
cp -r /opt/omegat/OmegaT-default/scripts/* /home/$USER/.capstan/scripts/
#add customized settings to prefs file
sed -i "39i <scripts_dir>/home/$USER/.capstan/scripts</scripts_dir>" ../config/omegat.prefs
cd /home/$USER
#Create a launch command
echo 'alias omegat_pisa="omegat --config-dir=/home/'$USER'/.capstan/config/ --config-file=/home/'$USER'/.capstan/config/omegat.prefs"' >> .bashrc
source /home/$USER/.bashrc
#Clean up tmp folder
rm -rf /home/$USER/.capstan/tmp
echo "OmegaT customization has been installed!"
echo "Run omegat_pisa to use it"
@msoutopico
Copy link
Author

msoutopico commented Apr 22, 2020

pi@raspberry:~/Dev $ sudo bash omtlinux_installer.sh
This script will install OmegaT and install the PISA 2021 customiser
Downloading and installing OmegaT
--2020-04-22 20:40:42-- http://sourceforge.net/projects/omegat/files/OmegaT%20-%20Latest/OmegaT%204.2.0/OmegaT_4.2.0_Beta_Linux_64.tar.bz2/download
S'està resolent sourceforge.net (sourceforge.net)… 216.105.38.13
S'està connectant a sourceforge.net (sourceforge.net)|216.105.38.13|:80… connectat.
HTTP: s'ha enviat la petició, s'està esperant una resposta… 301 Moved Permanently
Ubicació: https://sourceforge.net/projects/omegat/files/OmegaT%20-%20Latest/OmegaT%204.2.0/OmegaT_4.2.0_Beta_Linux_64.tar.bz2/download [es segueix]
--2020-04-22 20:40:48-- https://sourceforge.net/projects/omegat/files/OmegaT%20-%20Latest/OmegaT%204.2.0/OmegaT_4.2.0_Beta_Linux_64.tar.bz2/download
S'està connectant a sourceforge.net (sourceforge.net)|216.105.38.13|:443… connectat.
HTTP: s'ha enviat la petició, s'està esperant una resposta… 404 Not Found
2020-04-22 20:40:50 ERROR: 404 Not Found.

Extracting OmegaT

bzip2: Compressed file ends unexpectedly;
perhaps it is corrupted? Possible reason follows.
bzip2: Inappropriate ioctl for device
Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Child returned status 2
tar: Error is not recoverable: exiting now
omtlinux_installer.sh: línia 67: cd: OmegaT*: El fitxer o directori no existeix
Install OmegaT
bash: linux-install.sh: El fitxer o directori no existeix
Downloading the customization files
Extracting customization files
Archive: config.zip
extracting: config/customisation.properties
inflating: config/omegat.autotext
inflating: config/omegat.prefs
inflating: config/omt-package-config.properties
inflating: config/uiLayout.xml
inflating: config/version_notes.txt
Archive: plugins.zip
inflating: plugins/okapiFiltersForOmegaT-1.6-m36-capstan.jar
inflating: plugins/plugin-omt-package-1.4.1.jar
Archive: scripts.zip
inflating: scripts/check_rules.groovy
inflating: scripts/clear_source_target_folders.groovy
inflating: scripts/clear_volatile_backup.groovy
inflating: scripts/convert_arab2indic_global.groovy
inflating: scripts/convert_arab2indic_segm.groovy
inflating: scripts/convert_indic2arab_global.groovy
inflating: scripts/copy_source.groovy
inflating: scripts/FlushUneditedEntriesCLI.groovy
inflating: scripts/FlushUneditedEntries.groovy
inflating: scripts/jxl.jar
inflating: scripts/merge_2lang.groovy
creating: scripts/project_changed/
inflating: scripts/project_changed/pisaconv.groovy
creating: scripts/properties/
inflating: scripts/properties/tagwipe.properties
inflating: scripts/pseudoxlate.groovy
inflating: scripts/replace_strip_tags.groovy
inflating: scripts/strip_bidi_marks.groovy
inflating: scripts/strip_html_tags.groovy
inflating: scripts/strip_pseudotags.groovy
inflating: scripts/tagwipe.groovy
inflating: scripts/updateConfigBundle.groovy
inflating: scripts/write_project2excel.groovy
inflating: scripts/write_project2TMX.groovy
inflating: scripts/write_sel_files2TMXv2.groovy
inflating: scripts/write_source2file.groovy
inflating: scripts/write_source_target.groovy
inflating: scripts/write_table_for_TMX.groovy
inflating: scripts/write_table.groovy
inflating: scripts/xliter8_latn2cyrl.groovy
inflating: scripts/zip_current_project.groovy
Applying the customization
cp: ha fallat stat() sobre '/opt/omegat/OmegaT-default/scripts/*': El fitxer o directori no existeix
OmegaT customization has been installed!
run omegat_pisa to use it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment