config() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  # If there's no config file by that name, mv it over:
  if [ ! -r $OLD ]; then
    mv $NEW $OLD
  elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
    # toss the redundant copy
    rm $NEW
  fi
  # Otherwise, we leave the .new copy for the admin to consider...
}

preserve_perms() {
  NEW="$1"
  OLD="$(dirname $NEW)/$(basename $NEW .new)"
  if [ -e $OLD ]; then
    cp -a $OLD ${NEW}.incoming
    cat $NEW > ${NEW}.incoming
    mv ${NEW}.incoming $NEW
  fi
  config $NEW
}

preserve_perms etc/rc.d/rc.llama.cpp.new
config etc/rc.d/rc.llama.cpp.new

( cd usr/lib64 ; rm -rf libggml-base.so )
( cd usr/lib64 ; ln -sf libggml-base.so.0 libggml-base.so )
( cd usr/lib64 ; rm -rf libggml-base.so.0 )
( cd usr/lib64 ; ln -sf libggml-base.so.0.18.0 libggml-base.so.0 )
( cd usr/lib64 ; rm -rf libggml-cpu.so )
( cd usr/lib64 ; ln -sf libggml-cpu.so.0 libggml-cpu.so )
( cd usr/lib64 ; rm -rf libggml-cpu.so.0 )
( cd usr/lib64 ; ln -sf libggml-cpu.so.0.18.0 libggml-cpu.so.0 )
( cd usr/lib64 ; rm -rf libggml-rpc.so )
( cd usr/lib64 ; ln -sf libggml-rpc.so.0 libggml-rpc.so )
( cd usr/lib64 ; rm -rf libggml-rpc.so.0 )
( cd usr/lib64 ; ln -sf libggml-rpc.so.0.18.0 libggml-rpc.so.0 )
( cd usr/lib64 ; rm -rf libggml-vulkan.so )
( cd usr/lib64 ; ln -sf libggml-vulkan.so.0 libggml-vulkan.so )
( cd usr/lib64 ; rm -rf libggml-vulkan.so.0 )
( cd usr/lib64 ; ln -sf libggml-vulkan.so.0.18.0 libggml-vulkan.so.0 )
( cd usr/lib64 ; rm -rf libggml.so )
( cd usr/lib64 ; ln -sf libggml.so.0 libggml.so )
( cd usr/lib64 ; rm -rf libggml.so.0 )
( cd usr/lib64 ; ln -sf libggml.so.0.18.0 libggml.so.0 )
( cd usr/lib64 ; rm -rf libllama-common.so )
( cd usr/lib64 ; ln -sf libllama-common.so.0 libllama-common.so )
( cd usr/lib64 ; rm -rf libllama-common.so.0 )
( cd usr/lib64 ; ln -sf libllama-common.so.0.0.10208 libllama-common.so.0 )
( cd usr/lib64 ; rm -rf libllama.so )
( cd usr/lib64 ; ln -sf libllama.so.0 libllama.so )
( cd usr/lib64 ; rm -rf libllama.so.0 )
( cd usr/lib64 ; ln -sf libllama.so.0.0.10208 libllama.so.0 )
( cd usr/lib64 ; rm -rf libmtmd.so )
( cd usr/lib64 ; ln -sf libmtmd.so.0 libmtmd.so )
( cd usr/lib64 ; rm -rf libmtmd.so.0 )
( cd usr/lib64 ; ln -sf libmtmd.so.0.0.10208 libmtmd.so.0 )
