dominic bu gisti düzenledi 1 week ago. Düzenlemeye git
Değişiklik yok
dominic bu gisti düzenledi 1 week ago. Düzenlemeye git
Değişiklik yok
dominic bu gisti düzenledi 1 week ago. Düzenlemeye git
1 file changed, 135 insertions
install-betterbird.sh(dosya oluşturuldu)
| @@ -0,0 +1,135 @@ | |||
| 1 | + | #!/bin/bash | |
| 2 | + | # https://github.com/Betterbird/thunderbird-patches/blob/main/install-on-linux/install-betterbird.sh | |
| 3 | + | ||
| 4 | + | # Betterbird installation script for Linux, adapted from | |
| 5 | + | # https://github.com/risaer/betterbird-dirty-update/blob/main/updateBetterbird.sh | |
| 6 | + | ||
| 7 | + | # Configuration | |
| 8 | + | lang="en-US" # Language options: en-US, de, fr, es-ES, ja, it, nl, pt-BR, ru. | |
| 9 | + | version="release" # Version options: previous, release, latest, future. Only 'release' is guaranteed to work. | |
| 10 | + | tmpDir="$HOME/tmp/betterbird" | |
| 11 | + | tmpFile="" # Will be filled by script. | |
| 12 | + | tmpLocFile="$tmpDir/download.txt" | |
| 13 | + | installDir="/opt" | |
| 14 | + | desktopFile="/usr/share/applications/eu.betterbird.Betterbird.desktop" # Do not change this configuration without reading comment in registerMIME(). | |
| 15 | + | backupDir="/opt/betterbird_backup_$(date +%Y%m%d%H%M)" | |
| 16 | + | logFile="/var/log/betterbird/update.log" | |
| 17 | + | ||
| 18 | + | # Helper function for logging | |
| 19 | + | echoLog() { | |
| 20 | + | echo "$(date '+%Y-%m-%d %H:%M:%S') - $1" | tee -a "$logFile" | |
| 21 | + | } | |
| 22 | + | ||
| 23 | + | mkdir -p "$(dirname "$logFile")" 2>/dev/null | |
| 24 | + | if [ $? -ne 0 ]; then | |
| 25 | + | echo "This script likely needs superuser access since it writes to /var and /opt." | |
| 26 | + | echo "Can't create logfile directory $(dirname "$logFile"). Exiting." | |
| 27 | + | exit 1 | |
| 28 | + | fi | |
| 29 | + | touch "$logFile" 2>/dev/null | |
| 30 | + | if [ $? -ne 0 ]; then | |
| 31 | + | echo "This script likely needs superuser access since it writes to /var and /opt." | |
| 32 | + | echo "Can't touch logfile at $logFile. Exiting." | |
| 33 | + | exit 1 | |
| 34 | + | fi | |
| 35 | + | ||
| 36 | + | echoLog "Script started." | |
| 37 | + | ||
| 38 | + | # Functions for installation steps | |
| 39 | + | checkIfBetterbirdIsRunning() { | |
| 40 | + | if pgrep -f betterbird-bin > /dev/null; then | |
| 41 | + | echoLog "Betterbird is running. Please close it first." | |
| 42 | + | exit 1 | |
| 43 | + | fi | |
| 44 | + | } | |
| 45 | + | ||
| 46 | + | downloadUpdate() { | |
| 47 | + | mkdir -p "$tmpDir" | |
| 48 | + | wget -q -O "$tmpLocFile" "https://www.betterbird.eu/downloads/getloc.php?os=linux&lang=$lang&version=$version" | |
| 49 | + | read -r fileToDownload < "$tmpLocFile" | |
| 50 | + | fileToDownload=$(basename "$fileToDownload") | |
| 51 | + | # extract major version (3 characters after "betterbird-") | |
| 52 | + | major=${fileToDownload:11:3} | |
| 53 | + | shaFile="https://www.betterbird.eu/downloads/sha256-${major}.txt" # Name of sha256 file | |
| 54 | + | echoLog "Download found: $fileToDownload." | |
| 55 | + | tmpFile="$tmpDir/$fileToDownload" | |
| 56 | + | ||
| 57 | + | # Delete old downloads. | |
| 58 | + | find "$tmpDir" -type f ! -name "$fileToDownload" -delete | |
| 59 | + | ||
| 60 | + | if [ -f "$tmpFile" ]; then | |
| 61 | + | echoLog "$tmpFile already present. Exiting." | |
| 62 | + | exit 0; | |
| 63 | + | fi | |
| 64 | + | ||
| 65 | + | echoLog "Starting download..." | |
| 66 | + | wget -q -O "$tmpFile" "https://www.betterbird.eu/downloads/get.php?os=linux&lang=$lang&version=$version" | |
| 67 | + | echoLog "Downloaded archive." | |
| 68 | + | } | |
| 69 | + | ||
| 70 | + | checkHash() { | |
| 71 | + | local hash=$(sha256sum "$tmpFile" | awk '{print $1}') | |
| 72 | + | wget -q -O "$tmpDir/sha256.txt" "$shaFile" | |
| 73 | + | local update=$(grep $hash $tmpDir/sha256.txt | awk '{print $2}') | |
| 74 | + | if [ "$update" == "" ]; then | |
| 75 | + | echoLog "Hash $hash not found in $shaFile." | |
| 76 | + | exit 1 | |
| 77 | + | else | |
| 78 | + | echoLog "Hash check OK, hash matched ${update:1}." | |
| 79 | + | fi | |
| 80 | + | rm "$tmpDir/sha256.txt" | |
| 81 | + | } | |
| 82 | + | ||
| 83 | + | backup() { | |
| 84 | + | echoLog "Checking if existing Betterbird installation needs to be backed up..." | |
| 85 | + | if [ -d "$installDir/betterbird" ]; then | |
| 86 | + | echoLog "Creating backup of the current installation..." | |
| 87 | + | cp -r "$installDir/betterbird" "$backupDir" | |
| 88 | + | if [ $? -eq 0 ]; then | |
| 89 | + | echoLog "Backup successfully created at $backupDir." | |
| 90 | + | else | |
| 91 | + | echoLog "Failed to create backup." | |
| 92 | + | fi | |
| 93 | + | else | |
| 94 | + | echoLog "No existing Betterbird installation found to backup." | |
| 95 | + | fi | |
| 96 | + | } | |
| 97 | + | ||
| 98 | + | extract() { | |
| 99 | + | rm -rf "$installDir/betterbird" | |
| 100 | + | tar xf "$tmpFile" -C "$installDir" | |
| 101 | + | echoLog "Extracted to $installDir/betterbird." | |
| 102 | + | } | |
| 103 | + | ||
| 104 | + | createDesktopFile() { | |
| 105 | + | wget -q -O "$desktopFile" "https://raw.githubusercontent.com/Betterbird/thunderbird-patches/main/metadata/eu.betterbird.Betterbird.desktop" | |
| 106 | + | sed -i -e 's|Exec=betterbird %u|Exec='"$installDir"'/betterbird/betterbird %u|' "$desktopFile" | |
| 107 | + | sed -i -e 's|Icon=eu.betterbird.Betterbird|Icon='"$installDir"'/betterbird/chrome/icons/default/default256.png|' "$desktopFile" | |
| 108 | + | echoLog "Desktop file created." | |
| 109 | + | } | |
| 110 | + | ||
| 111 | + | registerMIME() { | |
| 112 | + | # This function registers Betterbird as the default application for handling mailto: links. | |
| 113 | + | # It uses xdg-mime to set and query the default MIME handler. | |
| 114 | + | # Note: If you move the desktop file to a non-standard directory, you may need to update $XDG_DATA_DIRS. | |
| 115 | + | # This environment variable tells the desktop environment where to find desktop files. | |
| 116 | + | # Example: export XDG_DATA_DIRS="/desktop/file/directory:$XDG_DATA_DIRS" | |
| 117 | + | # For more details, see: https://specifications.freedesktop.org/menu-spec/latest/ar01s02.html | |
| 118 | + | xdg-mime default eu.betterbird.Betterbird.desktop x-scheme-handler/mailto | |
| 119 | + | echoLog "MIME handler for x-scheme-handler/mailto registered." | |
| 120 | + | ||
| 121 | + | # Query the current default application set for handling mailto: links. | |
| 122 | + | local mimeHandler=$(xdg-mime query default x-scheme-handler/mailto) | |
| 123 | + | echoLog "Current default MIME handler for mailto: $mimeHandler." | |
| 124 | + | } | |
| 125 | + | ||
| 126 | + | # Main execution | |
| 127 | + | checkIfBetterbirdIsRunning | |
| 128 | + | downloadUpdate | |
| 129 | + | checkHash | |
| 130 | + | backup | |
| 131 | + | extract | |
| 132 | + | createDesktopFile | |
| 133 | + | registerMIME | |
| 134 | + | echoLog "Install successful: Betterbird installed in $installDir/betterbird." | |
| 135 | + | echoLog "Desktop file in $desktopFile." | |
Daha yeni
Daha eski