natanprog

fb_vanilla_ub24-25.sh

Oct 27th, 2025
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 4.22 KB | Source Code | 0 0
  1. #!/bin/bash
  2.  
  3. # Please contact IBSurgeon with any question regarding this script: [email protected]
  4. # This script is provided AS IS, without any warranty.
  5. # This script is licensed under IDPL https://firebirdsql.org/en/initial-developer-s-public-license-version-1-0/
  6.  
  7. FB_VER=2.5
  8. FB_URL="https://github.com/FirebirdSQL/firebird/releases/download/R2_5_9/FirebirdCS-2.5.9.27139-0.amd64.tar.gz"
  9. FTP_URL="https://cc.ib-aid.com/download/distr"
  10.  
  11. SYSCTL=/etc/sysctl.conf
  12. SYS_STR="vm.max_map_count"
  13.  
  14. TMP_DIR=$(mktemp -d)
  15. OLD_DIR=$(pwd -P)
  16.  
  17. MOD_SCRIPT=$TMP_DIR/fb/scripts/postinstall.sh
  18. #------------------------------------------------------------------------
  19. #  register/start/stop server using systemd
  20.  
  21. SYSTEMCTL=systemctl
  22. SYSTEMD_DIR=/usr/lib/systemd/system
  23. [ -d $SYSTEMD_DIR ] || SYSTEMD_DIR=/lib/systemd/system
  24.  
  25. PROC_SKT_CTRL=firebird.socket
  26. PROC_SVC_CTRL=firebird@.service
  27. THRD_SVC_CTRL=firebird.service
  28.  
  29. download_file(){
  30.     url=$1
  31.     tmp=$2
  32.     name=$3
  33.     fname=$(basename -- "$url")
  34.  
  35.     echo "Downloading $name..."
  36.     m=$(curl -w "%{http_code}" --location $url --output $tmp/$fname --progress-bar)
  37.     r=$?
  38.     s=""
  39.     case $m in
  40.     "200") s="OK";;
  41.     "404") exit_script 1 "File not found on server";;
  42.        * ) exit_script 1 "HTTP error ($m)";;
  43.     esac
  44.     case $r in
  45.        0) echo "OK";;    
  46.       23) exit_script $r "Write error";;
  47.       67) exit_script $r "Wrong login / password";;
  48.       78) exit_script $r "File $url does not exist on server";;
  49.        *) exit_script $r "Error downloading file ($r)";;
  50.     esac
  51. }
  52.  
  53. exit_script(){
  54.     p1=$1
  55.     p2=$2
  56.     if [[ -z "$p1" ]]; then
  57.         p1=0                # p1 was empty
  58.     fi
  59.     # cleanup
  60.     if [ -d $TMP_DIR ]; then rm -rf $TMP_DIR; fi
  61.     if [ $p1 -eq 0 ]; then      # normal termination
  62.         if [[ -z "$p2" ]]; then
  63.             p2="Script terminated normally"
  64.         fi
  65.         echo $p2
  66.         exit 0
  67.     else
  68.         if [[ -z "$p2" ]]; then
  69.             p2="An error occured during script execution ($p1)"
  70.         fi
  71.         echo $p2
  72.         exit $p1
  73.     fi
  74. }
  75.  
  76. if grep -q $SYS_STR $SYSCTL; then
  77.     echo "Parameter $SYS_STR already set in $SYSCTL"
  78. else
  79.     echo "$SYS_STR = 256000" >> $SYSCTL
  80.     sysctl -p
  81. fi
  82.  
  83. apt update
  84. apt install --no-install-recommends -y ca-certificates net-tools wget unzip gettext libncurses6 curl tar tzdata locales sudo xz-utils file libtommath1 libicu74
  85.  
  86. ln -s libtommath.so.1 /usr/lib/x86_64-linux-gnu/libtommath.so.0
  87. ln -s libncurses.so.6 /usr/lib/x86_64-linux-gnu/libncurses.so.5
  88. locale-gen "en_US.UTF-8"
  89.  
  90. download_file $FB_URL $TMP_DIR "FB installer"
  91. download_file $FTP_URL/$FB_VER/confv.tar.xz $TMP_DIR "FB config files"
  92. download_file $FTP_URL/$FB_VER/systemd-files.tar.xz $TMP_DIR "Systemd support"
  93.  
  94. echo Extracting FB installer ==================================================
  95.  
  96. mkdir $TMP_DIR/fb $TMP_DIR/conf $TMP_DIR/systemd-files
  97. tar xvf $TMP_DIR/*.gz -C $TMP_DIR/fb --strip-components=1 > /dev/null || exit_script 1 "Error unpacking FB archive"
  98. tar xvf $TMP_DIR/confv.tar.xz -C $TMP_DIR/conf > /dev/null || exit_script 1 "Error unpacking conf archive"
  99. tar xvf $TMP_DIR/systemd-files.tar.xz -C $TMP_DIR/systemd-files  > /dev/null || exit_script 1 "Error unpacking systemd files"
  100.  
  101. echo Running FB installer =====================================================
  102.  
  103. if [ -e $SYSTEMD_DIR/$PROC_SKT_CTRL -a -e $SYSTEMD_DIR/$PROC_SVC_CTRL -a -e $SYSTEMD_DIR/$THRD_SVC_CTRL ]; then
  104.         echo "All systemd control files found."
  105. else
  106.         echo "One or more systemd control files not found. Copying to $SYSTEMD_DIR"
  107.         cp $TMP_DIR/systemd-files/{$PROC_SKT_CTRL,$PROC_SVC_CTRL,$THRD_SVC_CTRL} $SYSTEMD_DIR
  108.         echo "Reloading systemd units"
  109.         systemctl daemon-reload
  110. fi
  111.  
  112. sed -i 's/^startService classic$/#startService classic/g' $MOD_SCRIPT
  113. sed -i 's/^updateInetdServiceEntry$/#updateInetdServiceEntry/g' $MOD_SCRIPT
  114. sed -i 's|replaceLineInFile /etc/services|#replaceLineInFile /etc/services|g' $MOD_SCRIPT
  115.  
  116. cd $TMP_DIR/fb
  117.  
  118. yes "masterkey" | ./install.sh
  119. cp $TMP_DIR/systemd-files/changeSystemdMode.sh /opt/firebird/bin/
  120.  
  121. cd $OLD_DIR
  122. cp -rf $TMP_DIR/conf/*.conf /opt/firebird
  123. chown firebird:firebird /opt/firebird/firebird.conf /opt/firebird/aliases.conf
  124. /opt/firebird/bin/changeSystemdMode.sh thread
  125.  
  126. echo Postinstall actions ======================================================
  127.  
  128. exit_script 0
  129.  
  130.  
Advertisement
Add Comment
Please, Sign In to add comment