#! /bin/sh # Rocky9 not-yet compatible (bundle needs to be fixed first) . /usr/src/k_framework/main.sh VERSION="1.1.3" SCRIPT_NAME="XSendFile Install" k_config_details k_detect_os #------VARIABLES------------- #----- FUNCTIONS ------------ check_if_xsend_configured_for_backups() { XSendFile_options=`grep XSendFile /etc/httpd/conf/httpd.conf | wc -l` if [ "$XSendFile_options" == "2" ]; then return 0 #OK else return 1 # Failed fi } xsendfile_module_installed(){ # This seem to work on c6, c7, R9 httpd -t -D DUMP_MODULES 2>&1 | grep -Fq xsendfile_module 2>/dev/null } #--------- Main -------------- k_start if [ "$GUI_PRESENT" == "1" ]; then # is gui present in this system? if xsendfile_module_installed; then report "Xsendfile Apache module is already active" 0 else report "Xsendfile Apache module is not installed, will try to install and activate now" 0 3 yum -y install httpd-devel cd /home/$SYSTEM_GUI_DIR source "/etc/profile.d/rvm.sh" # on R9 bundle (why not bundler???) is accessible here already if [[ $centos_version == 7 ]]; then gem_dir=`ruby -e 'print Gem.default_dir'` report "gem_dir: $gem_dir" 3 if [ -d $gem_dir ]; then k_symlink_create $gem_dir/bin/bundle /usr/bin/bundle # fix to bundle: command not found - fuck x2 this ruby BS k_symlink_create $gem_dir/bin/ruby_executable_hooks /usr/bin/ruby_executable_hooks else # second try to fix this BS gem_dir="/usr/local/rvm/gems/ruby-2.2.2/bin" if [ -d $gem_dir ]; then k_symlink_create $gem_dir/bundle /usr/bin/bundle k_symlink_create $gem_dir/ruby_executable_hooks /usr/bin/ruby_executable_hooks else report "gem dir cannot be located. bundle command could fail" 1 fi fi fi bundle if [[ $ROXKY9 == 1 ]]; then # Latest 1.0 version (still last update 2012) taken from here # https://github.com/nmaier/mod_xsendfile/ # Supposed to work better for Apache 2.4 cd /usr/src/k_framework/helpers/gui/xsendfile1.0 || report "Failed to cd /usr/src/k_framework/helpers/gui/xsendfile1.0" 1 apxs -cia mod_xsendfile.c else cd /usr/src/k_framework/helpers/gui/xsendfile || report "Failed to cd /usr/src/k_framework/helpers/gui/xsendfile" 1 apxs -cia mod_xsendfile.c fi check_if_xsend_configured_for_backups if [ "$XSendFile_options" == "2" ]; then report "XSendFile already configured" 0 else if [ "$XSendFile_options" == "0" ]; then # options are not present yet sed -i '/xsendfile_module/a\XSendFile on' /etc/httpd/conf/httpd.conf sed -i "/XSendFile on/a\XSendFilePath \/usr\/local\/$SYSTEM_CONFIG_DIR\/backups\/" /etc/httpd/conf/httpd.conf check_if_xsend_configured_for_backups if [ "$XSendFile_options" == "2" ]; then report "XSendFile configured" 4 else report "Failed to configure XSendFile. Make sure that these lines are present in /etc/httpd/conf/httpd.conf after line 'LoadModule xsendfile_module /usr/lib/httpd/modules/mod_xsendfile.so'\n\nXSendFile on\nXSendFilePath /usr/local/$SYSTEM_CONFIG_DIR/backups/\n" 1 fi fi fi service httpd restart &> /dev/null if xsendfile_module_installed; then report "Xsendfile Apache module installed" 4 else report "Failed to install Xsendfile Apache module. Manual intervention is needed, please contact Kolmisoft staff" 1 EXIT_CODE=1 fi fi fi k_exit $EXIT_CODE