mirror of
https://github.com/AuxXxilium/arc-addons.git
synced 2025-02-23 12:21:18 +07:00
tree: fix more
Signed-off-by: AuxXxilium <info@auxxxilium.tech>
This commit is contained in:
parent
8e127be666
commit
93189b1f0f
@ -24,7 +24,7 @@ install_addon() {
|
||||
echo "[Service]"
|
||||
echo "Type=oneshot"
|
||||
echo "RemainAfterExit=yes"
|
||||
echo "ExecStart=/usr/bin/cpuinfo.sh $@"
|
||||
echo "ExecStart=/usr/bin/cpuinfo.sh ${2}"
|
||||
echo
|
||||
echo "[Install]"
|
||||
echo "WantedBy=multi-user.target"
|
||||
@ -53,7 +53,7 @@ uninstall_addon() {
|
||||
|
||||
case "${1}" in
|
||||
late)
|
||||
install_addon "${1}"
|
||||
install_addon "${1}" "${2}"
|
||||
;;
|
||||
uninstall)
|
||||
uninstall_addon "${1}"
|
||||
|
@ -1,110 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and 007revad <https://github.com/007revad>
|
||||
# Copyright (C) 2025 AuxXxilium <https://github.com/AuxXxilium>
|
||||
#
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
script="Sequential I/O SSD caches"
|
||||
color=no
|
||||
|
||||
# Check script is running as root
|
||||
if [[ $( whoami ) != "root" ]]; then
|
||||
echo -e "$script"
|
||||
echo -e "ERROR This script must be run as sudo or root!"
|
||||
if [[ $(whoami) != "root" ]]; then
|
||||
echo "$script"
|
||||
echo "ERROR: This script must be run as sudo or root!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Save options used
|
||||
args=("$@")
|
||||
|
||||
if [[ -z "$1" ]]; then
|
||||
kb="0"
|
||||
elif [[ "$1" == "true" ]]; then
|
||||
kb="0"
|
||||
elif [[ "$1" == "false" ]]; then
|
||||
kb="1024"
|
||||
fi
|
||||
# Determine kb value based on the first argument
|
||||
kb="0"
|
||||
[[ "$1" == "false" ]] && kb="1024"
|
||||
|
||||
# Show options used
|
||||
if [[ ${#args[@]} -gt "0" ]]; then
|
||||
echo "Using options: ${args[*]}"
|
||||
fi
|
||||
|
||||
[[ ${#args[@]} -gt 0 ]] && echo "Using options: ${args[*]}"
|
||||
|
||||
# Get list of volumes with caches
|
||||
cachelist=("$(sysctl dev | grep skip_seq_thresh_kb)")
|
||||
IFS=$'\n' caches=($(sort <<<"${cachelist[*]}")); unset IFS
|
||||
cachelist=$(sysctl dev | grep skip_seq_thresh_kb)
|
||||
IFS=$'\n' read -r -d '' -a caches <<< "$cachelist"
|
||||
|
||||
|
||||
if [[ ${#caches[@]} -lt "1" ]]; then
|
||||
if [[ ${#caches[@]} -lt 1 ]]; then
|
||||
echo "No caches found!" && exit 1
|
||||
fi
|
||||
|
||||
|
||||
# Get caches' current setting
|
||||
# Process each cache
|
||||
for c in "${caches[@]}"; do
|
||||
volume="$(echo "$c" | cut -d"+" -f2 | cut -d"." -f1)"
|
||||
kbs="$(echo "$c" | cut -d"=" -f2 | awk '{print $1}')"
|
||||
volumes+=("${volume}|$kbs")
|
||||
volume=$(echo "$c" | cut -d"+" -f2 | cut -d"." -f1)
|
||||
sysctl_dev=$(echo "$c" | cut -d"." -f2 | awk '{print $1}')
|
||||
key=$(echo "$c" | cut -d"=" -f1 | cut -d" " -f1)
|
||||
|
||||
sysctl_dev="$(echo "$c" | cut -d"." -f2 | awk '{print $1}')"
|
||||
sysctl_devs+=("$sysctl_dev")
|
||||
done
|
||||
# Set new cache kb value
|
||||
synosetkeyvalue /etc/sysctl.conf "$key" "$kb"
|
||||
echo "$kb" > "/proc/sys/dev/${sysctl_dev}/skip_seq_thresh_kb"
|
||||
|
||||
# Check and display the new settings
|
||||
check=$(synogetkeyvalue /etc/sysctl.conf "$key")
|
||||
case "$check" in
|
||||
0) echo "Sequential I/O for $volume cache is Enabled in /etc/sysctl.conf" ;;
|
||||
1024) echo "Sequential I/O for $volume cache is Disabled in /etc/sysctl.conf" ;;
|
||||
"") echo "Sequential I/O for $volume cache is not set in /etc/sysctl.conf" ;;
|
||||
*) echo "Sequential I/O for $volume cache is set to $check in /etc/sysctl.conf" ;;
|
||||
esac
|
||||
|
||||
# Show cache volumes and current setting
|
||||
if [[ ${#volumes[@]} -gt 0 ]]; then
|
||||
IFS="|" read -r cachevol setting <<< "${volumes}"
|
||||
cachevols=("$cachevol")
|
||||
fi
|
||||
|
||||
|
||||
for v in "${sysctl_devs[@]}"; do
|
||||
for c in "${cachevols[@]}"; do
|
||||
if [[ $v =~ "$c" ]]; then
|
||||
cachevol="$c"
|
||||
|
||||
# Get cache's key name
|
||||
cacheval="$(sysctl dev | grep skip_seq_thresh_kb | grep "$cachevol")"
|
||||
key="$(echo "$cacheval" | cut -d"=" -f1 | cut -d" " -f1)"
|
||||
|
||||
# Set new cache kb value
|
||||
val="$(synosetkeyvalue /etc/sysctl.conf "$key")"
|
||||
if [[ $val != "$kb" ]]; then
|
||||
synosetkeyvalue /etc/sysctl.conf "$key" "$kb"
|
||||
fi
|
||||
|
||||
if echo "$v" | grep "$cachevol" >/dev/null; then
|
||||
echo "$kb" > "/proc/sys/dev/${v}/skip_seq_thresh_kb"
|
||||
fi
|
||||
|
||||
# Check we set key value
|
||||
check="$(synogetkeyvalue /etc/sysctl.conf "$key")"
|
||||
if [[ "$check" == "0" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /etc/sysctl.conf"
|
||||
elif [[ "$check" == "1024" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /etc/sysctl.conf"
|
||||
elif [[ -z "$check" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /etc/sysctl.conf"
|
||||
else
|
||||
echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$check${Off} in /etc/sysctl.conf"
|
||||
fi
|
||||
|
||||
# Check we set proc/sys/dev
|
||||
val="$(cat /proc/sys/dev/"${v}"/skip_seq_thresh_kb)"
|
||||
if [[ "$val" == "0" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Green}Enabled${Off} in /proc/sys/dev\n"
|
||||
elif [[ "$val" == "1024" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}Disabled${Off} in /proc/sys/dev\n"
|
||||
elif [[ -z "$val" ]]; then
|
||||
echo -e "Sequential I/O for $cachevol cache is ${Red}not set${Off} in /proc/sys/dev\n"
|
||||
else
|
||||
echo -e "Sequential I/O for $cachevol cache is set to ${Cyan}$val${Off} in /proc/sys/dev\n"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
val=$(cat /proc/sys/dev/"${sysctl_dev}"/skip_seq_thresh_kb)
|
||||
case "$val" in
|
||||
0) echo "Sequential I/O for $volume cache is Enabled in /proc/sys/dev" ;;
|
||||
1024) echo "Sequential I/O for $volume cache is Disabled in /proc/sys/dev" ;;
|
||||
"") echo "Sequential I/O for $volume cache is not set in /proc/sys/dev" ;;
|
||||
*) echo "Sequential I/O for $volume cache is set to $val in /proc/sys/dev" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
exit 0
|
@ -1,7 +1,6 @@
|
||||
#!/usr/bin/env ash
|
||||
#
|
||||
# Copyright (C) 2025 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304>
|
||||
#
|
||||
# Copyright (C) 2025 AuxXxilium <https://github.com/AuxXxilium>
|
||||
# This is free software, licensed under the MIT License.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
@ -24,7 +23,7 @@ install_addon() {
|
||||
echo "[Service]"
|
||||
echo "Type=oneshot"
|
||||
echo "RemainAfterExit=yes"
|
||||
echo "ExecStart=/usr/bin/sequentialio.sh \$@"
|
||||
echo "ExecStart=/usr/bin/sequentialio.sh ${2}"
|
||||
echo
|
||||
echo "[Install]"
|
||||
echo "WantedBy=multi-user.target"
|
||||
@ -46,7 +45,7 @@ uninstall_addon() {
|
||||
|
||||
case "${1}" in
|
||||
late)
|
||||
install_addon "${1}"
|
||||
install_addon "${1}" "${2}"
|
||||
;;
|
||||
uninstall)
|
||||
uninstall_addon "${1}"
|
||||
|
Loading…
Reference in New Issue
Block a user