Skip to content

Commit 397ba4c

Browse files
Skamaslejaapmarcus
andauthored
Minor fix remove useless cat (hestiacp#5060)
* Minor fix remove useless cat * Fix format --------- Co-authored-by: Jaap Marcus <9754650+jaapmarcus@users.noreply.github.com>
1 parent 5c65e8f commit 397ba4c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

func/main.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ detect_os() {
8888
fi
8989
elif [ "$get_os_type" = "debian" ]; then
9090
OS_TYPE='Debian'
91-
OS_VERSION=$(cat /etc/debian_version | grep -o "[0-9]\{1,2\}" | head -n1)
91+
OS_VERSION=$(grep -o "[0-9]\{1,2\}" /etc/debian_version | head -n1)
9292
fi
9393
else
9494
OS_TYPE="Unsupported OS"
@@ -403,8 +403,8 @@ parse_object_kv_list() {
403403

404404
# Check if object is supended
405405
is_object_suspended() {
406-
if [ $2 = 'USER' ]; then
407-
spnd=$(cat $USER_DATA/$1.conf | grep "SUSPENDED='yes'")
406+
if [ "$2" = 'USER' ]; then
407+
spnd=$(grep "SUSPENDED='yes'" | $USER_DATA/$1.conf)
408408
else
409409
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf | grep "SUSPENDED='yes'")
410410
fi
@@ -416,7 +416,7 @@ is_object_suspended() {
416416
# Check if object is unsupended
417417
is_object_unsuspended() {
418418
if [ $2 = 'USER' ]; then
419-
spnd=$(cat $USER_DATA/$1.conf | grep "SUSPENDED='yes'")
419+
spnd=$(grep "SUSPENDED='yes'" "$USER_DATA/$1.conf")
420420
else
421421
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf | grep "SUSPENDED='yes'")
422422
fi
@@ -671,7 +671,7 @@ get_next_cronjob() {
671671

672672
# Sort cron jobs by id
673673
sort_cron_jobs() {
674-
cat $USER_DATA/cron.conf | sort -n -k 2 -t \' > $USER_DATA/cron.tmp
674+
sort -n -k 2 -t \' $USER_DATA/cron.conf > $USER_DATA/cron.tmp
675675
mv -f $USER_DATA/cron.tmp $USER_DATA/cron.conf
676676
}
677677

@@ -1479,12 +1479,12 @@ is_restart_format_valid() {
14791479

14801480
check_backup_conditions() {
14811481
# Checking load average
1482-
la=$(cat /proc/loadavg | cut -f 1 -d ' ' | cut -f 1 -d '.')
1482+
la=$(awk -F'[. ]' '{print $1}' /proc/loadavg)
14831483
# i=0
14841484
while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
14851485
echo -e "$(date "+%F %T") Load Average $la"
14861486
sleep 60
1487-
la=$(cat /proc/loadavg | cut -f 1 -d ' ' | cut -f 1 -d '.')
1487+
la=$(awk -F'[. ]' '{print $1}' /proc/loadavg)
14881488
done
14891489
}
14901490

0 commit comments

Comments
 (0)