#!/bin/bash #//////////////////////////////////// # DietPi Banner Script # #//////////////////////////////////// # Created by Daniel Knight / daniel.knight@dietpi.com / dietpi.com # #//////////////////////////////////// # # Info: # - filename /DietPi/dietpi/dietpi-banner # - Checks /DietPi/dietpi/.update_available # # Usage: # - dietpi-banner 0 = top section only # - dietpi-banner 1 = top section and credits + clear #//////////////////////////////////// setglobal INPUT = '0' if [[ $1 =~ ^-?[0-9]+$ ]] { setglobal INPUT = $1 } #Import DietPi-Globals --------------------------------------------------------------- source /DietPi/dietpi/func/dietpi-globals export G_PROGRAM_NAME='DietPi-Banner' #Import DietPi-Globals --------------------------------------------------------------- #///////////////////////////////////////////////////////////////////////////////////// #Globals #///////////////////////////////////////////////////////////////////////////////////// setglobal DIETPI_VERSION = ""$[sed -n 1p /DietPi/dietpi/.version].$[sed -n 2p /DietPi/dietpi/.version]"" setglobal IMAGE_ADDITIONAL_CREDITS = $[sed -n 8p /DietPi/dietpi/.hw_model] setglobal IP_ADDRESS = $[sed -n 4p /DietPi/dietpi/.network] setglobal IP_ADAPTER = $[sed -n 3p /DietPi/dietpi/.network] proc Update_Ip_Address{ /DietPi/dietpi/func/obtain_network_details setglobal IP_ADDRESS = $[sed -n 4p /DietPi/dietpi/.network] setglobal IP_ADAPTER = $[sed -n 3p /DietPi/dietpi/.network] } setglobal UPDATE_AVAILABLE = '0' setglobal UPDATE_AVAILABLE_VERSION = '''' #-1 = image required, other value=latest version proc Obtain_Update_Available{ #Update Available if test -f /DietPi/dietpi/.update_available { setglobal UPDATE_AVAILABLE = '1' setglobal UPDATE_AVAILABLE_VERSION = $[cat /DietPi/dietpi/.update_available] } } proc Hardware_Model_Print{ echo -e " \e[39;49;1mv$DIETPI_VERSION\e[0m \e[90m| $G_HW_MODEL_DESCRIPTION\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" } proc IPAddress_Print{ #Try to re-obtain IP if missing if test ! -n $IP_ADDRESS { Update_Ip_Address } echo -e " \e[39;49;1mIP $IP_ADAPTER\e[0m \e[90m| $IP_ADDRESS\e[0m\n \e[38;5;154m───────────────────────────────────────\e[0m" } #///////////////////////////////////////////////////////////////////////////////////// #Top section additional Text. Update available / MOTD etc #///////////////////////////////////////////////////////////////////////////////////// setglobal TEXT_TOP = '''' #///////////////////////////////////////////////////////////////////////////////////// # Banner Print #///////////////////////////////////////////////////////////////////////////////////// proc Banner_TopText_Extras{ #Update Available if sh-expr ' $UPDATE_AVAILABLE ' { if test $UPDATE_AVAILABLE_VERSION = '-1' { setglobal TEXT_TOP = '"\e[90m|\e[0m \e[91m\e[33;49;1mImage available\e[0m'" } else { setglobal TEXT_TOP = '"\e[90m|\e[0m \e[91m\e[33;49;1mUpdate available\e[0m'" } #Use TEXT_TOP for storing helpful info } else { #Helpful mode setglobal TEXT_TOP = ""\e[90m| $[date +"%R | %a %x]\e[0m"" } } proc Banner_Dietpi{ if sh-expr ' $INPUT == 1 ' { clear } echo -e " \e[38;5;154m───────────────────────────────────────\e[0m\n \e[39;49;1mDietPi \e[0m $TEXT_TOP \n \e[38;5;154m───────────────────────────────────────\e[0m" Hardware_Model_Print IPAddress_Print } proc Credits_Print{ echo -e '' echo -e "\e[90m Created by : Daniel Knight\e[0m" echo -e "\e[90m Web : http://DietPi.com\e[0m" echo -e "\e[90m Twitter : http://twitter.com/dietpi_\e[0m" echo -e "\e[90m Donate : http://goo.gl/pzISt9 \e[0m" if test -n $IMAGE_ADDITIONAL_CREDITS { echo -e '' echo -e "\e[90m Device image possible thanks to: $IMAGE_ADDITIONAL_CREDITS\e[0m" } echo -e "\e[90m DietPi's web hosting is powered by: MyVirtualServer.com\e[0m" echo -e '' echo -e "\e[1m dietpi-launcher\e[0m = All the DietPi programs in one place." echo -e "\e[1m dietpi-config\e[0m = Feature rich configuration tool for your device." echo -e "\e[1m dietpi-software\e[0m = Select optimized software for installation." #Update available? if sh-expr ' $UPDATE_AVAILABLE ' { if test $UPDATE_AVAILABLE_VERSION = '-1' { echo -e "\n\e[91m An updated DietPi image is available, please goto:\e[0m\n http://dietpi.com/download\n" } else { echo -e "\e[1m dietpi-update\e[0m = \e[91mRun now to update DietPi (from v$DIETPI_VERSION to v$UPDATE_AVAILABLE_VERSION).\e[0m" } } echo -e "\e[1m htop\e[0m = Resource monitor." echo -e "\e[1m cpu\e[0m = Shows CPU information and stats." echo -e '' } #///////////////////////////////////////////////////////////////////////////////////// # Main Loop #///////////////////////////////////////////////////////////////////////////////////// if sh-expr ' $INPUT == 0 ' { Obtain_Update_Available Banner_TopText_Extras Banner_Dietpi } elif sh-expr ' $INPUT == 1 ' { Obtain_Update_Available Banner_TopText_Extras Banner_Dietpi Credits_Print } #----------------------------------------------------------------------------------- exit 0 #-----------------------------------------------------------------------------------