#!/bin/bash
. /etc/kona/soundsystem.inc

trace healthcheck-in

#if [ "$(cat /etc/X11/default-display-manager)" != "/usr/bin/sddm" ]; then
#  em 104
#fi

if [ -x /usr/bin/pulseaudio ]; then
  if [ ! -f /usr/local/bin/pulseaudio ]; then
    cp /usr/bin/pulseaudio /usr/local/bin/pulseaudio
  fi
else
  if [ ! -L /usr/bin/pulseaudio ] && [ ! -f /usr/bin/pulseaudio ]; then
    cp /usr/local/bin/pulseaudio /usr/bin
  fi
fi

if [ -f /usr/local/etc/kona/update/rc-local.service ]; then
  cp /usr/local/etc/kona/update/rc-local.service /lib/systemd/system
fi
if [ -f /usr/local/etc/kona/update/prenetworking.sh ]; then
  cp /usr/local/etc/kona/update/prenetworking.sh /etc/kona
fi
if [ -f /usr/local/etc/kona/update/prenetworking.service ]; then
  cp /usr/local/etc/kona/update/prenetworking.service /lib/systemd/system
fi
if [ -L /etc/systemd/system/prenetworking.service ]; then
  if [ ! -z "$(ls -l /etc/systemd/system/prenetworking.service|grep null)" ]; then
    systemctl unmask prenetworking 2> /dev/null
  fi
fi

if [ -z "$(grep -i $kv/ /etc/kona/os-release)" ]; then
  for i in `ls /home`
  do
    if [ -f /home/$i/.Xauthority ]; then
      if [ -f /etc/kona/xrdpstart ]; then
        chown xrdp:xrdp /home/$i/.Xauthority
      else
        chown $i:$i /home/$i/.Xauthority
      fi
    fi
  done
fi

if [ -f /etc/kona/update/update.tgz ] && [ ! -f /etc/kona/update/update-*.tgz ]; then
  mkdir -p /usr/local/etc/kona
  tar xfz /etc/kona/update/update.tgz -C /usr/local/etc/kona
  if [ -x /usr/local/etc/kona/update/initdesktop.sh ]; then
    if [ ! -f /etc/kona/initdesktop-new.sh ]; then
      cp /usr/local/etc/kona/update/initdesktop.sh /etc/kona
    fi
  fi
  if [ -x /usr/local/etc/kona/update/initdesktop2.sh ]; then
    if [ ! -f /etc/kona/initdesktop2-new.sh ]; then
      cp /usr/local/etc/kona/update/initdesktop2.sh /etc/kona
    fi
  fi
  if [ -x /usr/local/etc/kona/update/initdesktop-root.sh ]; then
    cp /usr/local/etc/kona/update/initdesktop-root.sh /etc/kona
  fi
  if [ -f /usr/local/etc/kona/update/initdesktop-root.desktop ]; then
    cp /usr/local/etc/kona/update/initdesktop-root.desktop /root/.config/autostart
  fi
fi
if [ -f /usr/local/etc/kona/update/initdesktop.desktop ]; then
  cp /usr/local/etc/kona/update/initdesktop.desktop /etc/xdg/autostart
fi
for i in $(ls /home)
do
  if [ -d /home/$i/.config/autostart ]; then
    autostartexist="1"
#    if [ -f /usr/local/etc/kona/update/initdesktop.desktop ]; then
#      cp /usr/local/etc/kona/update/initdesktop.desktop /home/$i/.config/autostart
#    fi
    rm -f /home/$i/.config/autostart/initdesktop.desktop
  fi
done
if [ -z "$autostartexist" ]; then
  em 100
fi

if [ ! -f /etc/kona/initdesktop ]; then

  if [ -x /usr/local/etc/kona/update/wmcheck.sh ]; then
    cp /usr/local/etc/kona/update/wmcheck.sh /etc/kona
  fi

  if [ -x /usr/local/etc/kona/update/checksystem.sh ]; then
    cp /usr/local/etc/kona/update/checksystem.sh /etc/kona
  fi


  if [ -x /usr/local/etc/kona/update/verifyupdate.sh ]; then
    cp /usr/local/etc/kona/update/verifyupdate.sh /etc/kona
  fi

  [ -x /usr/local/etc/kona/update/dfc1 ] && mv /usr/local/etc/kona/update/dfc1 /usr/bin
fi
if [ -x /usr/local/etc/kona/update/systemcheck.sh ]; then
  cp /usr/local/etc/kona/update/systemcheck.sh /etc/kona
fi
if [ -x /usr/local/etc/kona/update/systemdiagnose.sh ]; then
  cp /usr/local/etc/kona/update/systemdiagnose.sh /etc/kona
fi
if [ -x /usr/local/etc/kona/update/checkwm.sh ]; then
  cp /usr/local/etc/kona/update/checkwm.sh /etc/kona
fi
if [ -x /usr/local/etc/kona/update/updatecheck.sh ]; then
 cp /usr/local/etc/kona/update/updatecheck.sh /etc/kona
fi


trace healthcheck-1

cp /etc/kona/os-release /etc
cp /etc/kona/lsb-release /etc

trace healthcheck-2
if [ -f /usr/bin/mpd ]; then
  if [ "$(ps xa|grep -v grep|grep /usr/bin/mpd)" ]; then
    killall mpd
    trace healthcheck-mpdstop
  fi
  rm -f /etc/xdg/autostart/mpd.desktop
  rm -f /etc/mpd.conf
  if [ -f /etc/kona/mpdstart ]; then
    chmod +x /usr/bin/mpd
    if [ -f /usr/bin/mpd.save ]; then
      chmod +x /usr/bin/mpd.save
    fi
  else
    chmod -x /usr/bin/mpd
  fi
fi

if [ ! -z "$(grep -i -e $kv/ -e black /etc/kona/os-release)" ]; then
  cp /etc/kona/lxde-logout /usr/bin
fi

#systemctl set-default graphical.target 2> /dev/null

#if [ ! -z "$(grep x86_64 /etc/kona/os-release)" ]; then
#  arch="x86_64"
#else
#  arch="i386"
#fi
trace healthcheck-3
if [ ! -f /etc/kona/headless ]; then
  if [ -z "$(pgrep upowerd)" ]; then
    systemctl start upower.service 2> /dev/null
    trace restart-upower
  fi
fi

if [ -x /usr/local/etc/kona/update/prelogout.sh ]; then
  cp /usr/local/etc/kona/update/prelogout.sh /etc/kona
fi

if [ -z "$(grep net.ifnames=0 /etc/default/grub)" ]; then
  cp /etc/kona/grub /etc/default
  update-grub
  trace upate-grub-ifnames=0
fi

if [ "$(cat /etc/kona/soundsystem)" = "jack" ]; then
  if [ -f /usr/bin/jackd ]; then
    chmod +x /usr/bin/jackd
  fi
  if [ -f /usr/bin/jackdbus ]; then
    chmod +x /usr/bin/jackdbus
  fi
else   
  if [ -x /usr/bin/jackd ]; then
    chmod -x /usr/bin/jackd
  fi
  if [ -x /usr/bin/jackdbus ]; then
    chmod -x /usr/bin/jackdbus
  fi
fi

trace healthcheck-autohqsd
if [ -f /etc/kona/autohqsd ] && [ -f /etc/kona/hqsd.conf ]; then
  while read line; do
    hqsd=""
    if [ "$(echo $line|cut -b1)" != "#" ]; then
      kernel="$(echo $line|cut -d' ' -f1)"
      hqsd="$(echo $line|cut -d' ' -f2)"
      if [ "$hqsd" != "0" ] && [ ! -z "$kernel" ]; then
        if [ ! -z "$(uname -r|grep "$kernel")" ]; then
	  break
	fi
      fi
    fi
    hqsd=""
  done < /etc/kona/hqsd.conf
fi
 
if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko)" ]; then
     rm /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org
     trace "same driver deleted(snd-pcm.ko)"
  fi
fi
if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org /lib/modules/$(uname -r)/kernel/sound/core/snd.ko)" ]; then
     rm /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org
     trace "same driver deleted(snd.ko)"
  fi
fi
if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst)" ]; then
     rm /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org
     trace "same driver deleted(snd.ko.zst)"
  fi
fi
if [ -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko)" ]; then
     rm /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org
     trace "same driver deleted(snd-usb-audio.ko)"
  fi
fi
if [ -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst)" ]; then
     rm /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org
     trace "same driver deleted(snd-usb-audio.ko.zst)"
  fi
fi
if [ -f /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org ]; then
  if [ -z "$(diff /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko)" ]; then
     rm /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org
     trace "same driver deleted(xhci-hcd.ko)"
  fi
fi
if ([ ! -z "$hqsd" ] || [ -f /etc/kona/fastmemcpy ]) && [ -f /etc/kona/soundrivers/$(uname -r)/snd-pcm.ko-avx.tgz ]; then
  if [ ! -f /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-pcm.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	touch /etc/kona/fastsoundriver
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-pcm.ko.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	touch /etc/kona/fastsoundriver
      fi
    fi
  fi
else
  if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org ]; then
    mv /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko.org /lib/modules/$(uname -r)/kernel/sound/core/snd-pcm.ko
  fi
fi
if ([ "$hqsd" = "2" ] || [ -f /etc/kona/fastmemcpy2 ]) && [ -f /etc/kona/soundrivers/$(uname -r)/snd.ko-avx.tgz ]; then
  if [ ! -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org ] && [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/core/snd.ko /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	touch /etc/kona/fastsoundriver
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/core/snd.ko /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd.ko.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	touch /etc/kona/fastsoundriver
      fi
    fi
  fi
  if [ ! -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org ] && [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        mv /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	zstd --rm /lib/modules/$(uname -r)/kernel/sound/core/snd.ko
	touch /etc/kona/fastsoundriver
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd.ko.tgz -C /lib/modules/$(uname -r)/kernel/sound/core
	zstd --rm /lib/modules/$(uname -r)/kernel/sound/core/snd.ko
	touch /etc/kona/fastsoundriver
      fi
    fi
  fi
else
  if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org ]; then
    mv /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.org /lib/modules/$(uname -r)/kernel/sound/core/snd.ko
  fi
  if [ -f /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org ]; then
    mv /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst.org /lib/modules/$(uname -r)/kernel/sound/core/snd.ko.zst
  fi
fi

if [ -f /etc/kona/hqusbaudio ] && [ -f /etc/kona/soundrivers/$(uname -r)/snd-usb-audio.ko-avx.tgz ]; then
  if [ ! -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org ] && [ -f lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-usb-audio.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/sound/usb
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-usb-audio.ko.tgz -C /lib/modules/$(uname -r)/kernel/sound/usb
      fi
      touch /etc/kona/hqusbaudiodriver
    fi
  fi
  if [ ! -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org ] && [ -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        mv /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-usb-audio.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/sound/usb
	zstd --rm /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        mv /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/snd-usb-audio.ko.tgz -C /lib/modules/$(uname -r)/kernel/sound/usb
	zstd --rm /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko
      fi
      touch /etc/kona/hqusbaudiodriver
    fi
  fi
else
  if [ -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org ]; then
    mv /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.org /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko
  fi
  if [ -f /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org ]; then
    mv /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst.org /lib/modules/$(uname -r)/kernel/sound/usb/snd-usb-audio.ko.zst
  fi
fi

if [ -f /etc/kona/hsusb ] && [ -f /etc/kona/soundrivers/$(uname -r)/xhci-hcd.ko-avx.tgz ]; then
  if [ ! -f /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org ]; then
    if [ -d /etc/kona/soundrivers/$(uname -r) ]; then
      if [ ! -z "$(grep avx /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/xhci-hcd.ko-avx.tgz -C /lib/modules/$(uname -r)/kernel/drivers/usb/host
      elif [ ! -z "$(grep sse2 /proc/cpuinfo)" ]; then
        cp /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org
	tar xfz /etc/kona/soundrivers/$(uname -r)/xhci-hcd.ko.tgz -C /lib/modules/$(uname -r)/kernel/drivers/host
      fi
      touch /etc/kona/hsusbdriver
    fi
  fi
else
  if [ -f /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org ]; then
    mv /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko.org /lib/modules/$(uname -r)/kernel/drivers/usb/host/xhci-hcd.ko
  fi
fi

rm -f /usr/share/xsessions/openbox.desktop
if [ -z "$(grep $kv/ /etc/kona/os-release)" ]; then
  if [ -x /usr/bin/openbox ] || [ -d /etc/xdg/openbox ]; then
    em 102
  fi
  for i in $(ls /home); do
    if [ -d /home/$i/.config ]; then
      if [ -d /home/$i/.config/openbox ]; then
        em 102
      fi
    fi
  done
else
  if [ -z "$(grep Exec /usr/share/xsessions/*|grep startlxde)" ]; then
    em 103
  fi
fi

if [ -f /etc/apt/sources.list.d/audirvana.list ] && [ -f /etc/apt/sources.list.d/audirvana.sources ]; then
  mv /etc/apt/sources.list.d/audirvana.list /etc/apt/sources.list.d/audirvana.list.bak
fi
if [ -f /etc/apt/sources.list.d/spotify.list ] && [ -f /etc/apt/sources.list.d/spotify.sources ]; then
  mv /etc/apt/sources.list.d/spotify.list /etc/apt/sources.list.d/spotify.list.bak
fi
if [ -f /etc/apt/sources.list.d/vivaldi.list ] && [ -f /etc/apt/sources.list.d/vivaldi.sources ]; then
  mv /etc/apt/sources.list.d/vivaldi.list /etc/apt/sources.list.d/vivaldi.list.bak
fi
if [ -f /etc/apt/sources.list.d/ubuntu.sources ] || [ -f /etc/apt/sources.list.d/ubuntu.list ]; then
  rm -f /etc/apt/sources.list
fi
#if [ -f /etc/apt/sources.list.d/google-chrome.list ]; then
#  modernize-sources
#fi

if [ ! -f /etc/kona/diretta/$(uname -r)/alsa_bridge.ko ]; then
  if [ -d /lib/modules/$(uname -r)/build ] && [ -d /etc/kona/DirettaHostSDK_148 ]; then
    mkdir -p /etc/kona/diretta/$(uname -r)
    pushd . > /dev/null
    cd /etc/kona/diretta
    make KERNELDIR=/lib/modules/$(uname -r)/build 2> /dev/null > /dev/null
    strip -d alsa_bridge.ko
    cp alsa_bridge.ko $(uname -r)
    if [ -z "$(systemctl list-unit-files|grep diretta_bridge_driver|grep disable)" ]; then
      systemctl restart diretta_bridge_driver 2> /dev/null
      touch /etc/kona/change_alsabridge
      chmod 777 /etc/kona/change_alsabridge
    fi
    popd > /dev/null
    trace "healthcheck - alsa bridge is build"
  fi
else
  if [ ! -z "$(diff /etc/kona/diretta/$(uname -r)/alsa_bridge.ko /etc/kona/diretta/alsa_bridge.ko)" ]; then
    cp /etc/kona/diretta/$(uname -r)/alsa_bridge.ko /etc/kona/diretta 
    if [ -z "$(systemctl list-unit-files|grep diretta_bridge_driver|grep disable)" ]; then
      systemctl restart diretta_bridge_driver 2> /dev/null
      touch /etc/kona/change_alsabridge
      chmod 777 /etc/kona/change_alsabridge
    fi
    trace "healthcheck - request syncAlsa restart by kernel change"
  fi
fi 

if [ -z "(systemctl list-unit-files|grep networkaudiod|grep disable)" ]; then
  if [ "$soundsystem" != "alsa" ]; then
    systemctl disable networkaudiod 2> /dev/null
  fi
fi


# recover splash
if [ -z "$(ls -l /etc/alternatives/default.plymouth|grep konalinux-logo)" ]; then
  if [ ! -f /etc/kona/update/update-desktop.sh ] && [ ! -z "$(grep default.plymouth /usr/local/etc/kona/update/update-desktop.sh)" ]; then
     cp /usr/local/etc/kona/update/update-desktop.sh /etc/kona/update
  fi
fi 

tmp=$(cat /etc/kona/tmp)
if [ -z "$(grep $tmp /etc/ld.so.conf.d/*)" ]; then
  cp /etc/kona/_konalinux.conf /etc/ld.so.conf.d
fi

rm -f /var/crash/*

trace healthcheck-out
