#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: https://mirrors.slickstack.io/bash/ss-install-adminer.txt ############################# #### path: /var/www/ss-install-adminer ############################################################# #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Reinstalls the entire Adminer module for SlickStack servers (idempotent) ############# #### module version: Adminer 4.8.1 ################################################################# #### sourced by: ss-install ######################################################################## #### bash aliases: ss install adminer, ss install phpmyadmin ####################################### #################################################################################################### ## SS-CONFIG MUST BE PROPERLY CONFIGURED AND ON CURRENT BUILD BEFORE RUNNING SS-INSTALL ## ## ENSURE YOUR SS-CONFIG BUILD REMAINS CURRENT BY RUNNING SS-UPDATE OCCASIONALLY ## ## source ss-config ## source /var/www/ss-config ## source ss-functions ## source /var/www/ss-functions ## BELOW THIS RELIES ON SS-CONFIG AND SS-FUNCTIONS #################################################################################################### #### TABLE OF CONTENTS (SS-Install-Adminer) ######################################################## #################################################################################################### ## this is a brief summary of the different code snippets you will find in this script ## ## each section should be commented so you understand what is being accomplished ## ## A. Touch Timestamp File ## B. Interactive Lockdown Prompt ## C. Message (Begin Script) ## D. Install Adminer (phpMyAdmin) ## E. Reset Permissions (Adminer) ## F. Exit Script Per Feedback #################################################################################################### #### A. SS-Install-Adminer: Touch Timestamp File ################################################### #################################################################################################### ## this is a dummy timestamp file that will remember the last time this script was run ## ## it can be useful for developer reference and is sometimes used by SlickStack ## ss_touch "${TIMESTAMP_SS_INSTALL_ADMINER}" #################################################################################################### #### B. SS-Install-Adminer: Interactive Lockdown Prompt ############################################ #################################################################################################### ## in case SS_LOCKDOWN is enabled this interactive prompt will ask before proceeding ## ## otherwise by default this script cannot run if lockdown is currently enabled ## if [[ "${SS_LOCKDOWN}" == "true" ]]; then read -r -p "Your SlickStack server has lockdown enabled, run ss-install-adminer anyways? [y/N]" response fi if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]] || [[ "${SS_LOCKDOWN}" != "true" ]]; then #################################################################################################### #### C. SS-Install-Adminer: Message (Begin Script) ################################################# #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be seen by sudo users who manually run this script in the shell ## ss_echo "${COLOR_INFO}Running ss-install-adminer... ${COLOR_RESET}" #################################################################################################### #### D. SS-Install-Adminer: Install Adminer (phpMyAdmin) ########################################### #################################################################################################### ## here we retrieve the latest version of adminer.php from our mirrors and install it ## ## note that adminer.php cannot be converted to UTF-8 or else it will break ## ## retrieve adminer.php ## ss_wget "${TMP_ADMINER_PHP}" "${GITHUB_ADMINER_PHP}" VALIDATE_TMP_ADMINER_PHP=$(grep 'Jakub Vrana' "${TMP_ADMINER_PHP}" 2> /dev/null) if [[ -z "${VALIDATE_TMP_ADMINER_PHP}" ]]; then ss_wget "${TMP_ADMINER_PHP}" "${GITLAB_ADMINER_PHP}" fi ## install adminer.php ## VALIDATE2_TMP_ADMINER_PHP=$(grep 'Jakub Vrana' "${TMP_ADMINER_PHP}" 2> /dev/null) if [[ -n "${VALIDATE2_TMP_ADMINER_PHP}" ]]; then if [[ "${SS_ADMINER_PUBLIC}" == "false" ]]; then ss_rm "${PATH_ADMINER_PHP}" ss_echo "${COLOR_ERROR}Adminer disabled in ss-config so skipping install... ${COLOR_RESET}" else ss_mv "${TMP_ADMINER_PHP}" "${PATH_ADMINER_PHP}" fi fi #################################################################################################### #### E. SS-Install-Adminer: Reset Permissions (Adminer) ############################################ #################################################################################################### ## run ss-perms-adminer ## source "${PATH_SS_PERMS_ADMINER}" #################################################################################################### #### F. SS-Install-Adminer: Exit Script Per Feedback ############################################### #################################################################################################### else exit 1 fi #################################################################################################### #### SlickStack: Reset Permissions (SlickStack Scripts) ############################################ #################################################################################################### ## we include this permissions reset in all cron jobs and bash scripts for redundancy ## ## chmod 0700 means only the root/sudo users can execute any SlickStack scripts ## ## THIS SNIPPET DOES NOT RELY ON SS-CONFIG OR SS-FUNCTIONS ## SNIPPET: ss bash scripts, ss cron jobs ## UPDATED: 02JUL2022 chown root:root /var/www/ss* ## must be root:root chown root:root /var/www/crons/*cron* ## must be root:root chown root:root /var/www/crons/custom/*cron* ## must be root:root chmod 0700 /var/www/ss* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/*cron* ## 0700 means only root/sudo can execute chmod 0700 /var/www/crons/custom/*cron* ## 0700 means only root/sudo can execute #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: https://sourceforge.net/p/adminer/bugs-and-features/630/ ## Ref: https://github.com/littlebizzy/slickstack/issues/91 ## Ref: https://stackoverflow.com/questions/226703/how-do-i-prompt-for-yes-no-cancel-input-in-a-linux-shell-script ## Ref: https://github.com/littlebizzy/slickstack/issues/196 ## SS_EOF