Several fixes to shell scripts
This commit is contained in:
		@@ -11,38 +11,27 @@ if ! ./lib/prerequisites.sh; then
 | 
				
			|||||||
fi
 | 
					fi
 | 
				
			||||||
source site.conf
 | 
					source site.conf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Installing bridgehead"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
_systemd_path=/etc/systemd/system/
 | 
					_systemd_path=/etc/systemd/system/
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Installing systemd units ..."
 | 
					echo -e "\nInstalling systemd units ..."
 | 
				
			||||||
cp -v \
 | 
					cp -v \
 | 
				
			||||||
	convenience/bridgehead\@.service \
 | 
					    convenience/bridgehead\@.service \
 | 
				
			||||||
	convenience/bridgehead-update\@.service \
 | 
					    convenience/bridgehead-update\@.service \
 | 
				
			||||||
	convenience/bridgehead-update\@.timer \
 | 
					    convenience/bridgehead-update\@.timer \
 | 
				
			||||||
	$_systemd_path
 | 
					    $_systemd_path
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Loading the bridgehead definitions in systemd"
 | 
					 | 
				
			||||||
systemctl daemon-reload
 | 
					systemctl daemon-reload
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Starting Project ${project} "
 | 
					if ! systemctl is-active --quiet bridgehead@"${project}"; then
 | 
				
			||||||
  if [ ! -f "/etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf" ]; then
 | 
					 | 
				
			||||||
    echo "Can't find local configuration file for bridgehead@${project} service. Please ensure that the file /etc/systemd/system/bridgehead@${project}.service.d/bridgehead.conf exists"
 | 
					 | 
				
			||||||
    exit
 | 
					 | 
				
			||||||
  fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  systemctl is-active --quiet bridgehead@"${project}"
 | 
					 | 
				
			||||||
  if [ ! $? -eq 0 ]; then
 | 
					 | 
				
			||||||
    echo "Starting bridgehead@${project} service ..."
 | 
					 | 
				
			||||||
    systemctl start bridgehead@"${project}"
 | 
					 | 
				
			||||||
    echo "Enabling autostart of bridgehead@${project}.service"
 | 
					    echo "Enabling autostart of bridgehead@${project}.service"
 | 
				
			||||||
    systemctl enable bridgehead@"${project}"
 | 
					    systemctl enable bridgehead@"${project}"
 | 
				
			||||||
    echo "Enabling nightly updates for bridgehead@${project}.service ..."
 | 
					    echo "Enabling nightly updates for bridgehead@${project}.service ..."
 | 
				
			||||||
    systemctl enable --now bridgehead-update@"${project}".timer
 | 
					    systemctl enable --now bridgehead-update@"${project}".timer
 | 
				
			||||||
  fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					echo -e "\nDone - now start your bridgehead by running\n\tsystemctl start bridgehead@${project}.service\nor by rebooting your machine."
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Switch back to execution directory;
 | 
					 | 
				
			||||||
cd -
 | 
					 | 
				
			||||||
# TODO: Configuration of the different modules
 | 
					# TODO: Configuration of the different modules
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,13 +1,15 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
### Note: Currently not complete, needs some features before useable for production
 | 
					### Note: Currently not complete, needs some features before useable for production
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source lib/functions.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if ! ./prerequisites.sh; then
 | 
					if ! ./prerequisites.sh; then
 | 
				
			||||||
    echo "Prerequisites failed, exiting"
 | 
					    log "Prerequisites failed, exiting"
 | 
				
			||||||
    exit
 | 
					    exit
 | 
				
			||||||
fi
 | 
					fi
 | 
				
			||||||
source site.conf
 | 
					source site.conf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "Starting bridgehead"
 | 
					log "Starting bridgehead"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ${project}
 | 
					cd ${project}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -15,4 +17,4 @@ docker-compose --env-file ../site-config/${project}.env up -d
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
cd ..
 | 
					cd ..
 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "The bridgehead should be in online in a few seconds"
 | 
					log "The bridgehead should be in online in a few seconds"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,7 +1,10 @@
 | 
				
			|||||||
echo "Stoping bridgehead"
 | 
					#!/bin/bash -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source lib/functions.sh
 | 
				
			||||||
source site.conf
 | 
					source site.conf
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					log "Stopping bridgehead"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ${project}
 | 
					cd ${project}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
docker-compose --env-file ../site-config/${project}.env down
 | 
					docker-compose --env-file ../site-config/${project}.env down
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,14 +1,11 @@
 | 
				
			|||||||
echo "Stoping systemd services and removing bridgehead"
 | 
					#!/bin/bash -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
source site.conf
 | 
					source site.conf
 | 
				
			||||||
 | 
					source lib/functions.sh
 | 
				
			||||||
 | 
					
 | 
				
			||||||
systemctl stop bridgehead@"${project}".service
 | 
					echo "Stopping systemd services and removing bridgehead ..."
 | 
				
			||||||
systemctl stop bridgehead-update@"${project}".timer
 | 
					 | 
				
			||||||
systemctl stop bridgehead-update@"${project}".service
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd /etc/systemd/system/
 | 
					for i in bridgehead\@.service bridgehead-update\@.timer bridgehead-update\@.service; do
 | 
				
			||||||
rm bridgehead\@.service
 | 
					  systemctl disable $i --now
 | 
				
			||||||
rm bridgehead-update\@.timer
 | 
					  rm -v /etc/systemd/system/$i
 | 
				
			||||||
rm bridgehead-update\@.service
 | 
					done
 | 
				
			||||||
 | 
					 | 
				
			||||||
cd - 
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,7 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
service="bridgehead"
 | 
					service="bridgehead"
 | 
				
			||||||
# Creates logs
 | 
					
 | 
				
			||||||
log() {
 | 
					source lib/functions.sh
 | 
				
			||||||
  echo "$(date +'%Y-%m-%d %T')" "$1:" "$2"
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
log "INFO" "Checking for updates of $service"
 | 
					log "INFO" "Checking for updates of $service"
 | 
				
			||||||
# check prerequisites
 | 
					# check prerequisites
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user