1 changed files with 78 additions and 67 deletions
@ -1,67 +1,78 @@ |
|||||
#!/bin/bash |
#!/bin/bash |
||||
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. |
||||
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\ |
||||
THEME = ${THEME}\\n\ |
THEME = ${THEME}\\n\ |
||||
DOMAIN = ${DOMAIN}\\n\ |
DOMAIN = ${DOMAIN}\\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" |
||||
|
|
||||
# Restore login.php |
IFS='"' |
||||
if [ ${DISABLE_THEME} = "true" ]; then |
set $(cat /etc/unraid-version) |
||||
echo "Restoring backup of login.php" |
UNRAID_VERSION="$2" |
||||
cp -p /usr/local/emhttp/login.php.backup /usr/local/emhttp/login.php |
IFS=$' \t\n' |
||||
exit 0 |
LOGIN_PAGE="/usr/local/emhttp/login.php" |
||||
fi |
# Changing file path to login.php if version >= 6.10 |
||||
|
if [[ "${UNRAID_VERSION}" =~ ^6.10.* ]]; then |
||||
# Backup login page if needed. |
echo "Unraid version: ${UNRAID_VERSION}, changing path to login page" |
||||
if [ ! -f /usr/local/emhttp/login.php.backup ]; then |
LOGIN_PAGE="/usr/local/emhttp/webGui/include/.login.php" |
||||
echo "Creating backup of login.php" |
fi |
||||
cp -p /usr/local/emhttp/login.php /usr/local/emhttp/login.php.backup |
|
||||
fi |
# Restore login.php |
||||
|
if [ ${DISABLE_THEME} = "true" ]; then |
||||
# Use correct domain style |
echo "Restoring backup of login.php" |
||||
case ${DOMAIN} in |
cp -p ${LOGIN_PAGE}.backup ${LOGIN_PAGE} |
||||
*"github.io"*) |
exit 0 |
||||
echo "Switching to github.io URL style" |
fi |
||||
DOMAIN="${DOMAIN}\/theme.park" |
|
||||
;; |
# Backup login page if needed. |
||||
esac |
if [ ! -f ${LOGIN_PAGE}.backup ]; then |
||||
|
echo "Creating backup of login.php" |
||||
# Adding stylesheets |
cp -p ${LOGIN_PAGE} ${LOGIN_PAGE}.backup |
||||
if ! grep -q ${DOMAIN} /usr/local/emhttp/login.php; then |
fi |
||||
echo "Adding stylesheet" |
|
||||
sed -i -e "\@<style>@i\ <link rel='stylesheet' href='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" /usr/local/emhttp/login.php |
# Use correct domain style |
||||
echo 'Stylesheet set to' ${THEME} |
case ${DOMAIN} in |
||||
fi |
*"github.io"*) |
||||
|
echo "Switching to github.io URL style" |
||||
# Adding/Removing javascript |
DOMAIN="${DOMAIN}\/theme.park" |
||||
if [ ${ADD_JS} = "true" ]; then |
;; |
||||
if ! grep -q ${JS} /usr/local/emhttp/login.php; then |
esac |
||||
if grep -q "<script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/" /usr/local/emhttp/login.php; then |
|
||||
echo "Replacing Javascript" |
# Adding stylesheets |
||||
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>" /usr/local/emhttp/login.php |
if ! grep -q ${DOMAIN} ${LOGIN_PAGE}; then |
||||
else |
echo "Adding stylesheet" |
||||
echo "Adding javascript" |
sed -i -e "\@<style>@i\ <link rel='stylesheet' href='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/${THEME}'>" ${LOGIN_PAGE} |
||||
sed -i -e "\@</body>@i\ <script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" /usr/local/emhttp/login.php |
echo 'Stylesheet set to' ${THEME} |
||||
fi |
fi |
||||
fi |
|
||||
else |
# Adding/Removing javascript |
||||
if grep -q ${JS} /usr/local/emhttp/login.php; then |
if [ ${ADD_JS} = "true" ]; then |
||||
echo "Removing javascript.." |
if ! grep -q ${JS} ${LOGIN_PAGE}; then |
||||
sed -i "/<script type='text\/javascript' src='https:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/d" /usr/local/emhttp/login.php |
if grep -q "<script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/" ${LOGIN_PAGE}; then |
||||
fi |
echo "Replacing Javascript" |
||||
fi |
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} |
||||
|
else |
||||
# Changing stylesheet |
echo "Adding javascript" |
||||
if ! grep -q ${TYPE}"/"${THEME} /usr/local/emhttp/login.php; then |
sed -i -e "\@</body>@i\ <script type='text/javascript' src='https://${DOMAIN}/css/addons/unraid/login-page/${TYPE}/js/${JS}'></script>" ${LOGIN_PAGE} |
||||
echo "Changing existing custom stylesheet.." |
fi |
||||
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}'>" /usr/local/emhttp/login.php |
fi |
||||
echo 'Stylesheet set to' ${THEME} |
else |
||||
fi |
if grep -q ${JS} ${LOGIN_PAGE}; then |
||||
|
echo "Removing javascript.." |
||||
|
sed -i "/<script type='text\/javascript' src='https:\/\/${DOMAIN}\/css\/addons\/unraid\/login-page/d" ${LOGIN_PAGE} |
||||
|
fi |
||||
|
fi |
||||
|
|
||||
|
# Changing stylesheet |
||||
|
if ! grep -q ${TYPE}"/"${THEME} ${LOGIN_PAGE}; then |
||||
|
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} |
||||
|
echo 'Stylesheet set to' ${THEME} |
||||
|
fi |
||||
|
Loading…
Reference in new issue