#!/bin/bash #################################################################################################### #### author: SlickStack ############################################################################ #### link: https://slickstack.io ################################################################### #### mirror: http://mirrors.slickstack.io/bash/ss-dos2unix.txt ##################################### #### path: /var/www/ss-dos2unix #################################################################### #### destination: n/a (not a boilerplate) ########################################################## #### purpose: Converts any DOS files in the SlickStack directory tree to Unix file format ########## #### module version: Ubuntu 20.04 LTS ############################################################## #### sourced by: ss core cron jobs, ss-update ###################################################### #### bash aliases: ss dos2unix ##################################################################### #################################################################################################### ## include SlickStack configuration ## source /var/www/ss-config ## include SlickStack functions ## source /var/www/ss-functions #################################################################################################### #### SS-DOS2Unix: Message (Begin Script) ########################################################### #################################################################################################### ## this is a simple message that announces to the shell the purpose of this bash script ## ## it will only be noticed by sudo users who manually call ss core bash scripts ## ## echo message ## echo -e "${PURPLE}Running ss-dos2unix: Converts any DOS files in the SlickStack directory tree to Unix file format... ${NOCOLOR}" sleep "$SLEEP_MESSAGE_BEGIN" #################################################################################################### #### SS-DOS2Unix: Install Ubuntu Package If Not Exists (dos2unix) ################################## #################################################################################################### ## here is a brief script to install dos2unix package if does not exist already on server ## ## this approach ensures this bash script is completely self-contained to function ## PACKAGE_DOS2UNIX="dos2unix" PACKAGE_DOS2UNIX_EXISTS=$(dpkg-query -W --showformat='${Status}\n' $PACKAGE_DOS2UNIX|grep "install ok installed") echo Checking for $PACKAGE_DOS2UNIX: $PACKAGE_DOS2UNIX_EXISTS if [ "" = "$PACKAGE_DOS2UNIX_EXISTS" ]; then echo "$PACKAGE_DOS2UNIX package not found. We will install the package before proceeding." sudo apt install $PACKAGE_DOS2UNIX fi #################################################################################################### #### SS-DOS2Unix: Convert DOS Files To Unix Files ################################################## #################################################################################################### ## this utility will search the SlickStack directories for any DOS files and conver them ## ## avoiding DOS formats (e.g. janky line breaks) helps ensure file compatibility ## find /var/www/html/ -type f -exec dos2unix -k -o -s {} \; #################################################################################################### #### SS-DOS2Unix: Touch Timestamp File (End Script) ################################################ #################################################################################################### ## 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 ## ## script timestamp ## touch /var/www/meta/.timestamp-ss-dos2unix #################################################################################################### #### SlickStack: External References Used To Improve This Script (Thanks, Interwebz) ############### #################################################################################################### ## Ref: https://askubuntu.com/questions/319307/reliably-check-if-a-package-is-installed-or-not ## Ref: https://stackoverflow.com/questions/1298066/check-if-an-apt-get-package-is-installed-and-then-install-it-if-its-not-on-linu ## SS_EOF