Skip to content

Commit

Permalink
Bashate fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TommyE123 committed Dec 4, 2017
1 parent 226a2c8 commit ac56cfa
Show file tree
Hide file tree
Showing 55 changed files with 123 additions and 153 deletions.
4 changes: 4 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ language: generic

sudo: required

before_install:
- sudo pip install bashate

script:
- sudo bash ./integration-tests/int-bashate.sh
- sudo bash ./integration-tests/int-apps-install-uninstall.sh

matrix:
Expand Down
16 changes: 8 additions & 8 deletions deluged/deluged-repository-configurator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
CODENAME=$(lsb_release -c -s)

case "$CODENAME" in
'squeeze'|'wheezy'|'jessie'|'stretch'|'sid')
APPREPOSITORYLINK=''
;;
*)
REPOPPA='YES'
APPREPOSITORYLINK='ppa:deluge-team/ppa'
REPRECVKEYSHORT='249AD24C'
;;
'squeeze'|'wheezy'|'jessie'|'stretch'|'sid')
APPREPOSITORYLINK=''
;;
*)
REPOPPA='YES'
APPREPOSITORYLINK='ppa:deluge-team/ppa'
REPRECVKEYSHORT='249AD24C'
;;
esac
6 changes: 3 additions & 3 deletions deluged/deluged-settings-configurator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ sudo sed -i "s@\"move_completed\": false@\"move_completed\": true@g" $APPSETTING
sudo sed -i "s@\"move_completed_path\": \"/home/$UNAME/Downloads\"@\"move_completed_path\": \"/home/$UNAME/Downloads/deluge/completed\"@g" $APPSETTINGS || { echo -e $RED"Modifying completed location in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }

#Set autoadd folder enabled & destination
sudo sed -i "s@\"autoadd_enable\": false@\"autoadd_enable\": true@g" $APPSETTINGS || { echo -e $RED"Modifying autoadd_enable in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }
sudo sed -i "s@\"autoadd_enable\": false@\"autoadd_enable\": true@g" $APPSETTINGS || { echo -e $RED"Modifying autoadd_enable in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }
sudo sed -i "s@\"autoadd_location\": \"/home/$UNAME/Downloads\"@\"autoadd_location\": \"/home/$UNAME/Downloads/deluge/autoadd\"@g" $APPSETTINGS || { echo -e $RED"Modifying watch location in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }

#Enable Remote Connection
sudo sed -i "s@\"allow_remote\": false@\"allow_remote\": true@g" $APPSETTINGS || { echo -e $RED"Modifying allow_remote in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }
sudo sed -i "s@\"allow_remote\": false@\"allow_remote\": true@g" $APPSETTINGS || { echo -e $RED"Modifying allow_remote in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }

#Set autoconnect in web.conf
sudo sed -i "s@\"default_daemon\": \"\"@\"default_daemon\": \"127.0.0.1:58846\"@g" /home/$UNAME/.config/deluge/web.conf || { echo -e $RED"Modifying default_daemon in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }
sudo sed -i "s@\"default_daemon\": \"\"@\"default_daemon\": \"127.0.0.1:58846\"@g" /home/$UNAME/.config/deluge/web.conf || { echo -e $RED"Modifying default_daemon in $APPSETTINGS file failed."$ENDCOLOR; exit 1; }
2 changes: 1 addition & 1 deletion deluged/deluged-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ source "$SCRIPTPATH/inc/commons.sh"
source "$SCRIPTPATH/inc/header.sh"
echo -e "${GREEN}AtoMiC $APPTITLE Update Script$ENDCOLOR"
source "$SCRIPTPATH/inc/pause.sh"
if DoesAppFolderExist; then
if DoesAppFolderExist; then
source "$SCRIPTPATH/inc/app-stop.sh"
source "$SCRIPTPATH/utils/nzbtomedia/nzbtomedia-update.sh"
source "$SCRIPTPATH/deluged/deluged-constants.sh"
Expand Down
2 changes: 1 addition & 1 deletion emby-server/emby-server-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ source "$SCRIPTPATH/inc/app-start.sh"
echo "Waiting for $APPTITLE to finish initial setup"
sleep 30
echo "Now stop and start again"
source "$SCRIPTPATH/inc/app-stop.sh"
source "$SCRIPTPATH/inc/app-stop.sh"
source "$SCRIPTPATH/inc/app-start.sh"
source "$SCRIPTPATH/inc/app-install-confirmation.sh"
source "$SCRIPTPATH/inc/thankyou.sh"
Expand Down
2 changes: 1 addition & 1 deletion emby-server/emby-server-repository-configurator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ fi

CODENAME=$(lsb_release -c -s)
if [ "$TEMPDIST" = '' ]; then
case "$CODENAME" in
case "$CODENAME" in
'sid')
TEMPDIST='Debian_Next'
;;
Expand Down
6 changes: 3 additions & 3 deletions headphones/headphones-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ source "$SCRIPTPATH/inc/app-autostart-configure.sh"
source "$SCRIPTPATH/inc/app-set-permissions.sh"
source "$SCRIPTPATH/inc/app-start.sh"
echo "Waiting for $APPTITLE to finish initial setup"
sleep 20
sleep 20
echo "Now stop to create the $APPSETTINGS file"
source "$SCRIPTPATH/inc/app-stop.sh"
source "$SCRIPTPATH/inc/app-stop.sh"
echo
echo 'Set to Network Access'
sudo sed -i "s@${ACCESSHOST}localhost@${ACCESSHOST}0.0.0.0@g" $APPSETTINGS || { echo -e $RED'Modifying '$ACCESSHOST' in '$APPSETTINGS' file failed.'$ENDCOLOR; exit 1; }

source "$SCRIPTPATH/inc/app-start.sh"
source "$SCRIPTPATH/inc/app-start.sh"

source "$SCRIPTPATH/inc/app-install-confirmation.sh"
source "$SCRIPTPATH/inc/thankyou.sh"
Expand Down
8 changes: 4 additions & 4 deletions inc/app-access-credentials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ echo
sleep 1

if grep -q "reset.sh" "$SCRIPTPATH/$APPNAME/$APPNAME-menu.sh"; then
RESETSUPPORT="If you forgot, you may use the AtoMiC $APPTITLE password reset utility."
RESETSUPPORT="If you forgot, you may use the AtoMiC $APPTITLE password reset utility."
else
RESETSUPPORT=''
fi
Expand All @@ -17,7 +17,7 @@ echo -e "--->${CYAN}Password: ${RED}Not displayed for security.$ENDCOLOR$RESETSU
if [[ -z $UIPASSSTATUS ]] && [[ ! -z $APPDEFAULTPASS ]]; then
echo -e "Try default password: $GREEN$APPDEFAULTPASS$ENDCOLOR"
fi
echo
echo
sleep 1

if [[ ! $APPUSESNGINX = 'YES' ]]; then
Expand All @@ -39,11 +39,11 @@ if [[ ! $APPUSESNGINX = 'YES' ]]; then
[[ -f /lib/systemd/system/$APPSYSTEMD ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD ]] ; then

echo -e "SYSTEMD $APPSYSTEMD found.$ENDCOLOR"
STATUS=$(systemctl is-active $APPSYSTEMD)
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD is currently: ${GREEN}$STATUS$ENDCOLOR"
echo -e "$APPSYSTEMD is currently: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD is currently: ${RED}$STATUS$ENDCOLOR"
fi
Expand Down
5 changes: 1 addition & 4 deletions inc/app-access-switch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ source "$SCRIPTPATH/inc/pause.sh"
if DoesAppFolderExist; then
source "$SCRIPTPATH/inc/app-settings-check.sh"

echo
sleep 2
echo
source "$SCRIPTPATH/inc/app-stop.sh"
sleep 2
echo
Expand All @@ -24,9 +23,7 @@ if DoesAppFolderExist; then
sudo sed -i "s@^${ACCESSHOST}localhost@${ACCESSHOST}0.0.0.0@g" $APPSETTINGS || { echo -e $RED'Modifying '$ACCESSHOST' in '$APPSETTINGS' file failed.'$ENDCOLOR; exit 1; }
fi

sleep 2
source "$SCRIPTPATH/inc/app-start.sh"
sleep 2
echo
echo -e $GREEN'--->All done. '$APPTITLE' access switch complete.'$ENDCOLOR

Expand Down
4 changes: 2 additions & 2 deletions inc/app-autostart-configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ echo
source "$SCRIPTPATH/inc/app-stop.sh"
echo
echo -e "$YELLOW--->Autostart configuring...$ENDCOLOR"
if IsSystemdSupported; then
if IsSystemdSupported; then
echo 'Using systemd'

source "$SCRIPTPATH/inc/app-init-remove.sh"
source "$SCRIPTPATH/inc/app-systemd-add.sh"
source "$SCRIPTPATH/$APPNAME/$APPNAME-systemd-update.sh"

elif [[ -d /etc/init.d ]]; then
elif [[ -d /etc/init.d ]]; then
echo 'Using sysv-init'

source "$SCRIPTPATH/inc/app-systemd-remove.sh"
Expand Down
8 changes: 4 additions & 4 deletions inc/app-autostart-remove-unrequired-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ echo
source "$SCRIPTPATH/inc/app-stop.sh"
echo
echo -e "$YELLOW--->Autostart Removing any unrequired files...$ENDCOLOR"
if IsSystemdSupported; then
if IsSystemdSupported; then
echo 'Using systemd so removing any sysv-init files'

source "$SCRIPTPATH/inc/app-init-remove.sh" >/dev/null
sudo systemctl daemon-reload
sudo systemctl enable $APPSYSTEMD
sudo systemctl enable $APPSYSTEMD

elif [[ -d /etc/init.d ]]; then
elif [[ -d /etc/init.d ]]; then
echo 'Using sysv-init so removing any systemd files'

source "$SCRIPTPATH/inc/app-systemd-remove.sh" >/dev/null
sudo chown $UNAME:$UGROUP /etc/init.d/$APPINITD
sudo update-rc.d $APPINITD defaults
else
else
echo -e "${RED}Unknown startup type.$ENDCOLOR"
fi
7 changes: 3 additions & 4 deletions inc/app-folders-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ sleep 1
echo -e "$YELLOW--->Creating $APPTITLE files / folders...$ENDCOLOR"

if [[ -f $SCRIPTPATH/utils/$APPNAME/$APPNAME-folders-list ]]; then
cp $SCRIPTPATH/utils/$APPNAME/$APPNAME-folders-list $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Creating folders list failed.$ENDCOLOR"; exit 1; }
cp $SCRIPTPATH/utils/$APPNAME/$APPNAME-folders-list $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Creating folders list failed.$ENDCOLOR"; exit 1; }
else
cp $SCRIPTPATH/$APPNAME/$APPNAME-folders-list $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Creating folders list failed.$ENDCOLOR"; exit 1; }
cp $SCRIPTPATH/$APPNAME/$APPNAME-folders-list $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Creating folders list failed.$ENDCOLOR"; exit 1; }
fi

sudo sed -i "s@APPPATH@$APPPATH@g" $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Replacing $APPTITLE path in folders list failed.$ENDCOLOR"; exit 1; }
sudo sed -i "s@APPSETTINGSDIR@$APPSETTINGSDIR@g" $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Replacing $APPTITLE path in folders list failed.$ENDCOLOR"; exit 1; }
sudo sed -i "s@UNAME@$UNAME@g" $SCRIPTPATH/tmp/$APPSHORTNAME-folders-list || { echo -e "${RED}Replacing username in folders list failed.$ENDCOLOR"; exit 1; }

#Need encapsulate the $folder for folders with spaces
while IFS= read -r folder
do
while IFS= read -r folder; do
echo -e 'Creating '$CYAN$folder$ENDCOLOR'...'
if [[ ! -d $folder ]]; then
mkdir -p "$folder"
Expand Down
6 changes: 3 additions & 3 deletions inc/app-init-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ if [[ -f /etc/init.d/$APPINITD ]]; then
sudo rm /etc/init.d/$APPINITD || { echo -e $RED'Warning! Removing init script failed.'$ENDCOLOR ; }
echo "/etc/init.d/$APPINITD init script removed"
else
echo "/etc/init.d/$APPINITD init script not found"
echo "/etc/init.d/$APPINITD init script not found"
fi

#Remove the PID file and folder if it exists
if [[ -d /var/run/$APPNAME ]]; then
sudo rm -r /var/run/$APPNAME
sudo rm -r /var/run/$APPNAME
fi

#Remove a conf file if there is one
Expand All @@ -30,5 +30,5 @@ if [[ -f /etc/default/$APPNAME ]]; then
sudo rm /etc/default/$APPNAME || { echo -e $RED'Warning! Removing default script failed.'$ENDCOLOR ; }
echo "/etc/default/$APPNAME default script removed"
else
echo "/etc/default/$APPNAME default script not found"
echo "/etc/default/$APPNAME default script not found"
fi
6 changes: 2 additions & 4 deletions inc/app-password-reset.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash
echo
echo
sleep 1
if [ ! -z $UINAMESTATUS ]; then
#echo 'old password line: '$PASSSEARCH$UIPASS
#echo 'new password line: '$PASSSEARCH$NEWPASS
if [[ ! -z $UINAMESTATUS ]]; then
echo -e $YELLOW'Setting temporary '$APPTITLE' WebUI password...'$ENDCOLOR
sed -i 's|'"$PASSSEARCH$UIPASS"'|'"$PASSSEARCH$NEWPASS"'|g' $APPSETTINGS || { echo -e $RED'Setting temporary password failed.'$ENDCOLOR ; exit 1; }
echo -e 'Password set to: '$GREEN$APPNEWPASS$ENDCOLOR
Expand Down
4 changes: 2 additions & 2 deletions inc/app-port-search.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

echo -e "$YELLOW--->Searching for possible port numbers...$ENDCOLOR"
if [[ -n $APPDPORT ]]; then
echo -e "${CYAN}Default port: $ENDCOLOR$GREEN$APPDPORT$ENDCOLOR found in AtoMiC-ToolKit config."
echo -e "${CYAN}Default port: $ENDCOLOR$GREEN$APPDPORT$ENDCOLOR found in AtoMiC-ToolKit config."
fi

if [[ $PORTSEARCH == "NA" ]] || [[ -z $APPSETTINGS ]]; then
echo -e "Cannot determine port set in $CYAN$APPTITLE$ENDCOLOR config."
else
PORTSTRING=$(grep "$PORTSEARCH" $APPSETTINGS | grep -v "https" | head -1 | sed -e "s#.*$PORTSEARCH\\(\\)#\\1#")
PORTSTRING=$(grep "$PORTSEARCH" $APPSETTINGS | grep -v "https" | head -1 | sed -e "s#.*$PORTSEARCH\\(\\)#\\1#")
if [[ -n $PORTSTRING ]]; then
echo -e "${CYAN}Configured port: $ENDCOLOR$GREEN${PORTSTRING//[!0-9]/}$ENDCOLOR found in $APPSETTINGS."
fi
Expand Down
2 changes: 1 addition & 1 deletion inc/app-repository-add.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if [ ! "$APPREPOSITORYLINK" = "" ]; then
else
#Add the key
echo "$APPREPOSITORYLINK" | sudo tee -a /etc/apt/sources.list.d/$APPREPOSITORYNAME.list

#Check if backup required and add if needed
if [ ! "$APPREPOSITORYLINKBACKUP" = "" ]; then
if [ "$GREPOUTBACK" = "" ]; then
Expand Down
9 changes: 4 additions & 5 deletions inc/app-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ if [[ $exitstatus = 0 ]]; then

echo
sleep 1

#http://www.cyberciti.biz/faq/bash-loop-over-file/
echo -e $YELLOW'--->Checking for existing files...'$ENDCOLOR
DATETIME=`date '+%m-%d-%Y_%H-%M'`

while IFS= read -r file
do

while IFS= read -r file; do
echo -e "Restoring $CYAN$file$ENDCOLOR..."
if [[ -f $file ]] || [[ -d $file ]]; then
NEWFILENAME=$file'_'$DATETIME
Expand All @@ -41,4 +40,4 @@ if [[ $exitstatus = 0 ]]; then
else
echo
echo -e "${RED}Restoring $APPTITLE backup cancelled.$ENDCOLOR"
fi
fi
2 changes: 1 addition & 1 deletion inc/app-set-permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ if [[ ! -z $APPSETTINGSDIR ]] && [[ -d $APPSETTINGSDIR ]]; then
sudo chown -R $UNAME:$UGROUP "$APPSETTINGSDIR"
sudo chmod -R 775 "$APPSETTINGSDIR"
sudo chmod -R g+s "$APPSETTINGSDIR"
echo -e "$CYAN$APPSETTINGSDIR$ENDCOLOR Done"
echo -e "$CYAN$APPSETTINGSDIR$ENDCOLOR Done"
fi
5 changes: 2 additions & 3 deletions inc/app-settings-check.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#!/bin/bash
if [ ! -f "$APPSETTINGS" ];
then
if [ ! -f "$APPSETTINGS" ]; then
echo -e $RED $APPSETTINGS 'not found. '$ENDCOLOR$APPTITLE' not installed or incompatible installation.
Please open '$APPNAME', and try saving the config first else you may need to reinstall. '$ENDCOLOR
Please open '$APPNAME', and try saving the config first else you may need to reinstall. '$ENDCOLOR
echo -e ' Exiting. If '$APPTITLE' is installed, use '$CYAN'sudo ./setup.sh'$ENDCOLOR' to start it.'
echo
cd $SCRIPTPATH
Expand Down
9 changes: 4 additions & 5 deletions inc/app-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ if IsSystemdSupported; then
[[ -f /lib/systemd/system/$APPSYSTEMD ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD ]] ; then

FOUND=1
sudo systemctl start "$APPSYSTEMD"
sleep 5
STATUS=$(systemctl is-active "$APPSYSTEMD")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD is now: ${GREEN}$STATUS$ENDCOLOR"
echo -e "$APPSYSTEMD is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD is now: ${RED}$STATUS$ENDCOLOR"
fi
Expand All @@ -22,13 +22,13 @@ if IsSystemdSupported; then
if [[ -f /etc/systemd/system/$APPSYSTEMD2 ]] || \
[[ -f /lib/systemd/system/$APPSYSTEMD2 ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD2 ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD2 ]] ; then
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD2 ]]; then
FOUND=1
sudo systemctl start "$APPSYSTEMD2"
sleep 5
STATUS=$(systemctl is-active "$APPSYSTEMD2")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD2 is now: ${GREEN}$STATUS$ENDCOLOR"
echo -e "$APPSYSTEMD2 is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD2 is now: ${RED}$STATUS$ENDCOLOR"
fi
Expand All @@ -41,4 +41,3 @@ fi
if [[ ! -z $FOUND ]] && [[ $FOUND = 0 ]]; then
echo -e "${RED}Startup file not found.$ENDCOLOR"
fi

10 changes: 5 additions & 5 deletions inc/app-stop.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
#!/bin/bash
echo
echo
echo -e "${YELLOW}--->Stopping $APPTITLE...$ENDCOLOR"

if IsSystemdSupported; then
if [[ -f /etc/systemd/system/$APPSYSTEMD ]] || \
[[ -f /lib/systemd/system/$APPSYSTEMD ]] || \
[[ -f /usr/lib/systemd/system/$APPSYSTEMD ]] || \
[[ -L /etc/systemd/system/multi-user.target.wants/$APPSYSTEMD ]] ; then

FOUND=1
sudo systemctl stop "$APPSYSTEMD"
STATUS=$(systemctl is-active "$APPSYSTEMD")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD is now: ${GREEN}$STATUS$ENDCOLOR"
echo -e "$APPSYSTEMD is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD is now: ${RED}$STATUS$ENDCOLOR"
fi
Expand All @@ -26,12 +26,12 @@ if IsSystemdSupported; then
sudo systemctl stop "$APPSYSTEMD2"
STATUS=$(systemctl is-active "$APPSYSTEMD2")
if [[ $STATUS = 'active' ]]; then
echo -e "$APPSYSTEMD2 is now: ${GREEN}$STATUS$ENDCOLOR"
echo -e "$APPSYSTEMD2 is now: ${GREEN}$STATUS$ENDCOLOR"
else
echo -e "$APPSYSTEMD2 is now: ${RED}$STATUS$ENDCOLOR"
fi
fi
fi
fi

if [[ -f /etc/init.d/$APPINITD ]]; then
FOUND=3
Expand Down
Loading

0 comments on commit ac56cfa

Please sign in to comment.