#!/bin/bash if [ "$LOGNAME" != "root" ] then echo "LosslessCut updater needs to be run as root!" exit fi #get latest LosslessCut version number latest_web=$(curl https://api.github.com/repos/mifi/lossless-cut/releases/latest -s|sed -n 's/"tag_name": "v\([0-9]\.[0-9]*\.[0-9]*\)",/\1/p'| sed -e 's/^[[:space:]]*//') #convert version numbers to integers for comparison web=$(echo "$latest_web" | sed 's/\.//g') if [ -f /opt/losslesscut/version.txt ]; then current_ver=$(cat /opt/losslesscut/version.txt) #convert version numbers to integers for comparison cur=$(echo "$current_ver" | sed 's/\.//g') fi if [[ "$cur" == "" ]]; then cur=0 fi #download and install only if web version greater than current version #if main web version doesn't exist, then install new main version if [[ ${web:0:8} -gt ${cur:0:8} ]]; then echo "Current LosslessCut version $current_ver, upgrading to version $latest_web" if [ ! -d /opt/losslesscut ]; then mkdir /opt/losslesscut fi cd /opt/losslesscut if [ -f LosslessCut-linux-x86_64.AppImage ]; then mv LosslessCut-linux-x86_64.AppImage LosslessCut-linux-x86_64.AppImage.old fi wget "https://github.com/mifi/lossless-cut/releases/download/v$latest_web/LosslessCut-linux-x86_64.AppImage" chmod 755 /opt/losslesscut/LosslessCut-linux-x86_64.AppImage echo "$latest_web" > /opt/losslesscut/version.txt if [ ! -f /usr/share/applications/losslesscut.desktop ]; then wget https://github.com/mifi/lossless-cut/raw/master/src/icon.svg cat >> /usr/share/applications/losslesscut.desktop <