Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- # Install eID klient v4.x on Linux
- # Note: There are Two installation methods: (1) running AppImage; or (2) extracting the AppImage into a folder. The latter is a continuation of the former installation method.
- # Note: This script is quite messy. It requires some refactoring and tests.
- # Note: Tested on Arch Linux.
- # TODO: Install D.Launcher (see a note below).
- # Installation method 1
- url='https://eidas.minv.sk/downloadservice/eidklient/linux/eID_klient_x86_64.tar.gz'
- temp='/dev/shm'
- tempFile="$temp/eID_klient_x86_64.tar.gz"
- tempFolder="$temp/eid_extracted"
- appImage="$tempFolder/eID_klient-x86_64.AppImage"
- # Download
- curl -Lo "$tempFile" "$url"
- # Extract
- mkdir "$tempFolder"
- tar xf "$tempFile" -C "$tempFolder"
- # Note: The AppImage is already executable in DEB according to my tests, however, it never hurts to make sure.
- sudo chmod +x "$appImage"
- # Run app
- # QT_QPA_PLATFORM='xcb' "$appImage"
- # Installation method 2
- appExtracted="$tempFolder/extracted"
- install_location='/opt/eid_usr' # Default: `/usr`
- current_user="$USER"
- appImageBasename="$(basename "$appImage")"
- # Note: Fron `Install.sh`, I copied only those commands that should be needed to be executed.
- # TODO: Extract `squashfs-root/` to `$tempFolder`.
- # appImageInstallSh=$(QT_QPA_PLATFORM='xcb' $appImage --appimage-extract 'Install.sh')
- # sudo chmod +x "$appImageInstallSh"
- # $appImageInstallSh $PATTERN $appImage $VERBOSE
- # Kill eID if it is running
- # Note: `EAC` comes from `install.sh`, `eID_Client` is the binary name and `EAC_MW_klient` is the binary name used by `eidklient`.
- pgrep EAC_MW_klient > /dev/null && sudo pkill EAC_MW_klient
- pgrep eID_Client > /dev/null && sudo pkill eID_Client
- pgrep EAC > /dev/null && sudo pkill EAC
- # Extract all files from `$appImage`
- mkdir -p "$appExtracted"
- (cd "$appExtracted" && QT_QPA_PLATFORM='xcb' "$appImage" --appimage-extract > /dev/null)
- # TODO: Is `xterm` used at runtime? Is it only installation dependency?
- # Note: `libpcsclite1` is provided by `pcsclite`.
- pacman -Syu pcsclite xterm fuse2
- # TODO: Remove eID klient files of previous installations, as well as `$install_location/` folder.
- # sudo rm -rf /usr/bin/EAC_MW_klient
- # sudo rm -rf "$install_location"
- # Copy all files from `$appExtracted/squashfs-root` to "$install_location"
- sudo mkdir -p "$install_location"/{bin/VirtualKeyboard,bin/eID_Client,lib/eID_klient}
- sudo cp -r "$appExtracted/squashfs-root"/* "$install_location"
- # Copy `$appImage` to `$install_location/lib/eID_klient/$appImageBasename`
- sudo cp "$appImage" "$install_location/lib/eID_klient/$appImageBasename"
- sudo chown "$current_user" "$install_location/lib/eID_klient/$appImageBasename"
- # Link new VirtualKeyboard
- sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/bin/VirtualKeyboard"
- # Link new eID_Client
- sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/bin/eID_Client"
- # Link VirtualKeyboard to new folder
- # Note: [from `install.sh`] Temporary Pkcs11 link fix.
- sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/lib/eID_klient/VirtualKeyboard"
- # Copy files needed for electronic signature to: $install_location/lib/eID_klient
- sudo cp -f "$appExtracted/squashfs-root/lib/libCardAPI.so" "$install_location/lib/eID_klient"
- sudo cp -f "$appExtracted/squashfs-root/lib/libbotan.so" "$install_location/lib/eID_klient"
- sudo cp -f "$appExtracted/squashfs-root/lib/libpkcs11_x64.so" "$install_location/lib/eID_klient"
- sudo cp -f "$appExtracted/squashfs-root/lib/libcrypto.so.1.0.2" "$install_location/lib/eID_klient"
- sudo cp -f "$appExtracted/squashfs-root/lib/libssl.so.1.0.2" "$install_location/lib/eID_klient"
- # Copy logo files/icons
- sudo tar -xf "$appExtracted/squashfs-root/share.tar" -C "$install_location"
- # Allow execution of `eID_klient.desktop`
- if [ "$install_location" != '/usr' ]; then
- sudo cp "$appExtracted/share/applications/eID_klient.desktop" /usr/share/applications
- # TODO: Update `/usr/share/applications/eID_klient.desktop` to use `$install_location` instead of `/usr`.
- fi
- sudo chmod +x /usr/share/applications/eID_klient.desktop
- # Copy .desktop files to startup folder
- # TODO: Should this be done by default? eID klient v4 has an option to enable running on startup.
- # sudo mkdir "$install_location/lib/eID_klient/startup"
- # sudo cp -f /usr/share/applications/eID_klient.desktop "$install_location/lib/eID_klient/startup"
- # Check if files needed for electronic signature were copied succesfully
- install_error() {
- echo 'Files were not copied successfully. Please try reinstalling the app.'
- exit 1
- }
- find "$install_location/lib/eID_klient"/libCardAPI* &> /dev/null || install_error
- find "$install_location/lib/eID_klient"/libbotan* &> /dev/null || install_error
- find "$install_location/lib/eID_klient"/libpkcs11_* &> /dev/null || install_error
- find "$install_location/lib/eID_klient"/libcrypto* &> /dev/null || install_error
- find "$install_location/lib/eID_klient"/libssl* &> /dev/null || install_error
- # TODO: Install Disig Web Signer (`$install_location/DisigWebSigner-Install.sh`).
- # TODO: Update `$install_location/qt.conf` to use `ecb` and thus eliminate `QT_QPA_PLATFORM='xcb'`.
- # Clean up
- rm -rf squashfs-root "$tempFile" "$tempFolder"
- # Run app
- # QT_QPA_PLATFORM='xcb' "$install_location/eID_Client"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement