melawy-refind-theme-lera-sugar/install.sh

40 lines
928 B
Bash
Raw Normal View History

2023-04-16 11:20:15 +05:00
#!/bin/bash
if [[ "$UID" != 0 ]]; then
echo "USER NOT ROOT"
sudo $0
exit
else
echo "USER IS ROOT"
fi
PWD=$(dirname $0)
ESP_PATH=$(bootctl --print-esp-path)
REFIND_CONF_PATH="${ESP_PATH}/EFI/refind/refind.conf"
2023-04-17 11:25:27 +05:00
THEME_PATH="${ESP_PATH}/EFI/refind/themes"
2023-04-16 11:20:15 +05:00
if [[ ! -d "$THEME_PATH" ]];then
mkdir -p "$THEME_PATH"
fi
2023-04-17 11:25:27 +05:00
THEME_NAME="melawy-lera-sugar"
2023-04-16 11:20:15 +05:00
2023-04-17 11:25:27 +05:00
cp -vrf --remove-destination --no-dereference --preserve=links "$PWD/$THEME_NAME" "$THEME_PATH/"
2023-04-16 11:20:15 +05:00
RESULT=$(grep "theme" $REFIND_CONF_PATH)
if [[ "$?" = "0" ]]; then
CURRENT_THEME=$(echo $RESULT | cut -d"/" -f2)
if [[ "$?" = "0" ]]; then
2023-04-17 11:25:27 +05:00
sed -e "s/$CURRENT_THEME/$THEME_NAME/g" -i $REFIND_CONF_PATH
2023-04-16 11:20:15 +05:00
fi
else
if [[ -z "$(tail -n 1 -c 1 $REFIND_CONF_PATH)" ]];then
2023-04-17 11:25:27 +05:00
echo "include themes/$THEME_NAME/theme.conf" >> $REFIND_CONF_PATH
2023-04-16 11:20:15 +05:00
else
2023-04-17 11:25:27 +05:00
echo -e "\ninclude themes/$THEME_NAME/theme.conf" >> $REFIND_CONF_PATH
2023-04-16 11:20:15 +05:00
fi
fi