Как исправить синтаксическую ошибку в Grub?

Это всегда становится истинным, потому что аргумент командной строки ur конфликтует с процессом проверки ur. Чтобы протестировать сценарий, добавьте sleep 60 в первую строку -скрипта и запустите его, как показано ниже

sh  script.sh ntpd & ps aux | grep ntpd
[1] 6401
root      6401  0.0  0.0 111940  1208 pts/3    S    16:40   0:00 sh script.sh ntpd

вы можете добавить grep -v script.sh, чтобы решить эту проблему, или простоpidof ntpd | wc -w

Попробуйте это,

is_runing=`ps aux | grep -v grep | grep "$1" | grep -v "$(basename $0)" | wc -l`
echo $is_runing
if [ "$is_runing" -gt 0 ]; then
   echo "OK: $1"
   exit 0
else
   echo "Problem: $1 is not running"
   exit 2
fi
0
29.11.2020, 11:57
1 ответ

Чтобы помочь вам в будущей отладке, я задокументировал ваш поиск ошибки, которую я сделал.

Проблема в строке 178.

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries.  Simply type the
# menu entries you want to add after this comment.  Be careful not to change
# the 'exec tail' line above.
 
 
 
if [ "${grub_platform}" == "pc" ]; then
fi                                            #<------that is line 178
### END /etc/grub.d/40_custom ###

Итак, проблема явно в 40_custom.

Об этих файлах сказано:

These files should not be modified unless you are a GRUB expert and understand what the changes will do. Even then you should always keep a backup copy of the original, working grub.cfg file. The specific files, 40_custom and 41_custom are intended to be used to generate user modifications to the GRUB configuration. You should still be aware of the consequences of any changes you make to these files and maintain a backup of the original grub.cfg file.

Вероятно, это дополнение, которое вы внесли в этот файл.

Опытные скриптеры уже заметили это

if [ "${grub_platform}" == "pc" ]; then 
    :
fi

решит вашу синтаксическую ошибку. Я прямо указываю на «синтаксическую» ошибку, потому что не знаю, каковы были ваши намерения.

Вы измените это в/etc/grub.d/40_custom(файле, который вы, вероятно, редактировали ), а не в grub.cfg, но это должно было быть ясно из комментария в этом файле:

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#
2
18.03.2021, 22:46

Теги

Похожие вопросы