Advertisement
tukusejssirs

eidklient_v4.x_installation

Oct 4th, 2022
1,320
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 5.33 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. # Install eID klient v4.x on Linux
  4.  
  5. # 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.
  6.  
  7. # Note: This script is quite messy. It requires some refactoring and tests.
  8.  
  9. # Note: Tested on Arch Linux.
  10.  
  11. # TODO: Install D.Launcher (see a note below).
  12.  
  13.  
  14. # Installation method 1
  15.  
  16. url='https://eidas.minv.sk/downloadservice/eidklient/linux/eID_klient_x86_64.tar.gz'
  17. temp='/dev/shm'
  18. tempFile="$temp/eID_klient_x86_64.tar.gz"
  19. tempFolder="$temp/eid_extracted"
  20. appImage="$tempFolder/eID_klient-x86_64.AppImage"
  21.  
  22. # Download
  23. curl -Lo "$tempFile" "$url"
  24.  
  25. # Extract
  26. mkdir "$tempFolder"
  27. tar xf "$tempFile" -C "$tempFolder"
  28.  
  29. # Note: The AppImage is already executable in DEB according to my tests, however, it never hurts to make sure.
  30. sudo chmod +x "$appImage"
  31.  
  32. # Run app
  33. # QT_QPA_PLATFORM='xcb' "$appImage"
  34.  
  35. # Installation method 2
  36.  
  37. appExtracted="$tempFolder/extracted"
  38. install_location='/opt/eid_usr'  # Default: `/usr`
  39. current_user="$USER"
  40. appImageBasename="$(basename "$appImage")"
  41. # Note: Fron `Install.sh`, I copied only those commands that should be needed to be executed.
  42. # TODO: Extract `squashfs-root/` to `$tempFolder`.
  43. # appImageInstallSh=$(QT_QPA_PLATFORM='xcb' $appImage --appimage-extract 'Install.sh')
  44. # sudo chmod +x "$appImageInstallSh"
  45. # $appImageInstallSh $PATTERN $appImage $VERBOSE
  46.  
  47. # Kill eID if it is running
  48. # Note: `EAC` comes from `install.sh`, `eID_Client` is the binary name and `EAC_MW_klient` is the binary name used by `eidklient`.
  49. pgrep EAC_MW_klient > /dev/null && sudo pkill EAC_MW_klient
  50. pgrep eID_Client > /dev/null && sudo pkill eID_Client
  51. pgrep EAC > /dev/null && sudo pkill EAC
  52.  
  53. # Extract all files from `$appImage`
  54. mkdir -p "$appExtracted"
  55. (cd "$appExtracted" && QT_QPA_PLATFORM='xcb' "$appImage" --appimage-extract > /dev/null)
  56.  
  57. # TODO: Is `xterm` used at runtime? Is it only installation dependency?
  58. # Note: `libpcsclite1` is provided by `pcsclite`.
  59. pacman -Syu pcsclite xterm fuse2
  60.  
  61. # TODO: Remove eID klient files of previous installations, as well as `$install_location/` folder.
  62. # sudo rm -rf /usr/bin/EAC_MW_klient
  63. # sudo rm -rf "$install_location"
  64.  
  65. # Copy all files from `$appExtracted/squashfs-root` to "$install_location"
  66. sudo mkdir -p "$install_location"/{bin/VirtualKeyboard,bin/eID_Client,lib/eID_klient}
  67. sudo cp -r "$appExtracted/squashfs-root"/* "$install_location"
  68.  
  69. # Copy `$appImage` to `$install_location/lib/eID_klient/$appImageBasename`
  70. sudo cp "$appImage" "$install_location/lib/eID_klient/$appImageBasename"
  71. sudo chown "$current_user" "$install_location/lib/eID_klient/$appImageBasename"
  72.  
  73. # Link new VirtualKeyboard
  74. sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/bin/VirtualKeyboard"
  75.  
  76. # Link new eID_Client
  77. sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/bin/eID_Client"
  78.  
  79. # Link VirtualKeyboard to new folder
  80. # Note: [from `install.sh`] Temporary Pkcs11 link fix.
  81. sudo ln -sf "$install_location/lib/eID_klient/$appImageBasename" "$install_location/lib/eID_klient/VirtualKeyboard"
  82.  
  83. # Copy files needed for electronic signature to: $install_location/lib/eID_klient
  84. sudo cp -f "$appExtracted/squashfs-root/lib/libCardAPI.so" "$install_location/lib/eID_klient"
  85. sudo cp -f "$appExtracted/squashfs-root/lib/libbotan.so" "$install_location/lib/eID_klient"
  86. sudo cp -f "$appExtracted/squashfs-root/lib/libpkcs11_x64.so" "$install_location/lib/eID_klient"
  87. sudo cp -f "$appExtracted/squashfs-root/lib/libcrypto.so.1.0.2" "$install_location/lib/eID_klient"
  88. sudo cp -f "$appExtracted/squashfs-root/lib/libssl.so.1.0.2" "$install_location/lib/eID_klient"
  89.  
  90. # Copy logo files/icons
  91. sudo tar -xf "$appExtracted/squashfs-root/share.tar" -C "$install_location"
  92.  
  93. # Allow execution of `eID_klient.desktop`
  94. if [ "$install_location" != '/usr' ]; then
  95.     sudo cp "$appExtracted/share/applications/eID_klient.desktop" /usr/share/applications
  96.  
  97.     # TODO: Update `/usr/share/applications/eID_klient.desktop` to use `$install_location` instead of `/usr`.
  98. fi
  99.  
  100. sudo chmod +x /usr/share/applications/eID_klient.desktop
  101.  
  102. # Copy .desktop files to startup folder
  103. # TODO: Should this be done by default? eID klient v4 has an option to enable running on startup.
  104. # sudo mkdir "$install_location/lib/eID_klient/startup"
  105. # sudo cp -f  /usr/share/applications/eID_klient.desktop "$install_location/lib/eID_klient/startup"
  106.  
  107. # Check if files needed for electronic signature were copied succesfully
  108. install_error() {
  109.   echo 'Files were not copied successfully. Please try reinstalling the app.'
  110.   exit 1
  111. }
  112.  
  113. find "$install_location/lib/eID_klient"/libCardAPI* &> /dev/null || install_error
  114. find "$install_location/lib/eID_klient"/libbotan* &> /dev/null || install_error
  115. find "$install_location/lib/eID_klient"/libpkcs11_* &> /dev/null || install_error
  116. find "$install_location/lib/eID_klient"/libcrypto* &> /dev/null || install_error
  117. find "$install_location/lib/eID_klient"/libssl* &> /dev/null || install_error
  118.  
  119. # TODO: Install Disig Web Signer (`$install_location/DisigWebSigner-Install.sh`).
  120.  
  121. # TODO: Update `$install_location/qt.conf` to use `ecb` and thus eliminate `QT_QPA_PLATFORM='xcb'`.
  122.  
  123. # Clean up
  124. rm -rf squashfs-root "$tempFile" "$tempFolder"
  125.  
  126. # Run app
  127. # QT_QPA_PLATFORM='xcb' "$install_location/eID_Client"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement