Browse Source

Add SCHEME env, + sed some fixes

pull/386/head
GilbN 3 years ago
parent
commit
b180226bd8
  1. 19
      css/addons/unraid/login-page/custom_login.sh

19
css/addons/unraid/login-page/custom_login.sh

@ -2,13 +2,16 @@
TYPE="retro-terminal" TYPE="retro-terminal"
THEME="green.css" THEME="green.css"
DOMAIN="theme-park.dev" # If you update the domain after the script has been run, You must disable and re enable JS or the whole theme. DOMAIN="theme-park.dev" # If you update the domain after the script has been run, You must disable and re enable JS or the whole theme.
SCHEME="https"
ADD_JS="true" ADD_JS="true"
JS="custom_text_header.js" JS="custom_text_header.js"
DISABLE_THEME="false" DISABLE_THEME="false"
echo -e "Variables set:\\n\ echo -e "Variables set:\\n\
TYPE = ${TYPE}\\n\
THEME = ${THEME}\\n\ THEME = ${THEME}\\n\
DOMAIN = ${DOMAIN}\\n\ DOMAIN = ${DOMAIN}\\n\
SCHEME = ${SCHEME}\\n\
ADD_JS = ${ADD_JS}\\n\ ADD_JS = ${ADD_JS}\\n\
JS = ${JS}\\n\ JS = ${JS}\\n\
DISABLE_THEME = ${DISABLE_THEME}\\n" DISABLE_THEME = ${DISABLE_THEME}\\n"
@ -48,31 +51,33 @@ esac
# Adding stylesheets # Adding stylesheets
if ! grep -q ${DOMAIN} ${LOGIN_PAGE}; then if ! grep -q ${DOMAIN} ${LOGIN_PAGE}; then
echo "Adding stylesheet" echo "Adding stylesheet"
sed -i -e "\@<style>@i\ <link rel='stylesheet' href='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" ${LOGIN_PAGE} sed -i -e "\@<style>@i\ <link data-tp='theme' rel='stylesheet' href='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" ${LOGIN_PAGE}
sed -i -e "\@<style>@i\ <link data-tp='base' rel='stylesheet' href='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${TYPE}-base.css'>" ${LOGIN_PAGE}
echo 'Stylesheet set to' ${THEME} echo 'Stylesheet set to' ${THEME}
fi fi
# Adding/Removing javascript # Adding/Removing javascript
if [ ${ADD_JS} = "true" ]; then if [ ${ADD_JS} = "true" ]; then
if ! grep -q ${JS} ${LOGIN_PAGE}; then if ! grep -q ${JS} ${LOGIN_PAGE}; then
if grep -q "<script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/" ${LOGIN_PAGE}; then if grep -q "<script type='text/javascript' src='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/" ${LOGIN_PAGE}; then
echo "Replacing Javascript" echo "Replacing Javascript"
sed -i "/<script type='text\/javascript' src='https:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/c <script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" ${LOGIN_PAGE} sed -i "/<script type='text\/javascript' src='${SCHEME}:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/c <script type='text/javascript' src='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" ${LOGIN_PAGE}
else else
echo "Adding javascript" echo "Adding javascript"
sed -i -e "\@</body>@i\ <script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" ${LOGIN_PAGE} sed -i -e "\@</body>@i\ <script type='text/javascript' src='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" ${LOGIN_PAGE}
fi fi
fi fi
else else
if grep -q ${JS} ${LOGIN_PAGE}; then if grep -q ${JS} ${LOGIN_PAGE}; then
echo "Removing javascript.." echo "Removing javascript.."
sed -i "/<script type='text\/javascript' src='https:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/d" ${LOGIN_PAGE} sed -i "/<script type='text\/javascript' src='${SCHEME}:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/d" ${LOGIN_PAGE}
fi fi
fi fi
# Changing stylesheet # Changing stylesheet
if ! grep -q ${TYPE}"/"${THEME} ${LOGIN_PAGE}; then if ! grep -q ${TYPE}/${THEME} ${LOGIN_PAGE}; then
echo "Changing existing custom stylesheet.." echo "Changing existing custom stylesheet.."
sed -i "/<link rel='stylesheet' href='https:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/c <link rel='stylesheet' href='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" ${LOGIN_PAGE} sed -i "/<link data-tp='theme' rel='stylesheet' href='${SCHEME}:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/c <link data-tp='theme' rel='stylesheet' href='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" ${LOGIN_PAGE}
sed -i "/<link data-tp='base' rel='stylesheet' href='${SCHEME}:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/c <link data-tp='base' rel='stylesheet' href='${SCHEME}://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${TYPE}-base.css'>" ${LOGIN_PAGE}
echo 'Stylesheet set to' ${THEME} echo 'Stylesheet set to' ${THEME}
fi fi

Loading…
Cancel
Save