@ -1094,12 +1094,18 @@ read_or_default() {
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					download_updates( )  { 
download_updates( )  { 
 
			
		
	
		
		
			
				
					
						ohai "Downloading updated scripts and config files" 
	ohai "Downloading updated scripts and config files" 
 
			
		
	
		
		
			
				
					
						local  onlineUpdated = " $( curl -fsSL " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /updated " ) " 
 
			
		
	
		
		
			
				
					
						if  [  ! " $onlineUpdated "  = =  ""  ] ;  then 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $UPDATES_DIR /install.sh "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /install.sh " 
		curl -fsSL -o " $UPDATES_DIR /install.sh "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /install.sh " 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $UPDATES_DIR /deployment.env "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/deployment.env " 
		curl -fsSL -o " $UPDATES_DIR /deployment.env "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/deployment.env " 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $UPDATES_DIR /nightscout.env "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/nightscout.env " 
		curl -fsSL -o " $UPDATES_DIR /nightscout.env "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/nightscout.env " 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $UPDATES_DIR /docker-compose.yml "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/docker-compose.yml " 
		curl -fsSL -o " $UPDATES_DIR /docker-compose.yml "  " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /templates/docker-compose.yml " 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $PROFANITY_DB_FILE "  "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/profanity.db" 
		curl -fsSL -o " $PROFANITY_DB_FILE "  "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/profanity.db" 
 
			
		
	
		
		
			
				
					
							curl -fsSL -o " $RESERVED_DB_FILE "  "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/reserved.db" 
		curl -fsSL -o " $RESERVED_DB_FILE "  "https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/profanity/templates/reserved.db" 
 
			
		
	
		
		
			
				
					
						else 
 
			
		
	
		
		
			
				
					
							onlineUpdated = "error" 
 
			
		
	
		
		
			
				
					
						fi 
 
			
		
	
		
		
			
				
					
						echo  " $onlineUpdated "  >" $UPDATES_DIR /downloaded " 
 
			
		
	
		
		
			
				
					
					} }  
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					download_if_needed( )  { 
download_if_needed( )  { 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -1107,7 +1113,7 @@ download_if_needed() {
 
			
		
	
		
		
			
				
					
						local  lastDownload = $( read_or_default " $UPDATES_DIR /downloaded "  "" ) 
	local  lastDownload = $( read_or_default " $UPDATES_DIR /downloaded "  "" ) 
 
			
		
	
		
		
			
				
					
						local  timestampNow = $( date +%s) 
	local  timestampNow = $( date +%s) 
 
			
		
	
		
		
			
				
					
						local  updateCheck = $UPDATE_CHECK 
	local  updateCheck = $UPDATE_CHECK 
 
			
		
	
		
		
			
				
					
						if  ( ( ( timestampNow - lastCheck)  > updateCheck) )  ||  [  " $lastDownload "  = =  ""  ]  ||  ( forceUpdateCheck  = =  1) ) ;  then 
	if  ( ( ( timestampNow - lastCheck)  > updateCheck) )  ||  [  " $lastDownload "  = =  ""  ]  ||  [ " $lastDownload "  = =  "error"  ]  ||   (( forceUpdateCheck  = =  1) ) ;  then 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
							echo  " $timestampNow "  >" $UPDATES_DIR /timestamp " 
		echo  " $timestampNow "  >" $UPDATES_DIR /timestamp " 
 
			
		
	
		
		
			
				
					
							ohai "Checking if new version is available..." 
		ohai "Checking if new version is available..." 
 
			
		
	
		
		
			
				
					
							local  onlineUpdated = " $( curl -fsSL " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /updated " ) " 
		local  onlineUpdated = " $( curl -fsSL " https://gitea.dzienia.pl/shared/mikrus-installer/raw/branch/ $UPDATE_CHANNEL /updated " ) " 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -1115,7 +1121,6 @@ download_if_needed() {
 
			
		
	
		
		
			
				
					
							if  [  " $onlineUpdated "  = =  " $lastDownload "  ]  &&  ( ( forceUpdateCheck  = =  0) ) ;  then 
		if  [  " $onlineUpdated "  = =  " $lastDownload "  ]  &&  ( ( forceUpdateCheck  = =  0) ) ;  then 
 
			
		
	
		
		
			
				
					
								msgok "Latest update already downloaded" 
			msgok "Latest update already downloaded" 
 
			
		
	
		
		
			
				
					
							else 
		else 
 
			
		
	
		
		
			
				
					
								echo  " $onlineUpdated "  >" $UPDATES_DIR /downloaded " 
 
			
		
	
		
		
			
				
					
								download_updates
			download_updates
 
			
		
	
		
		
			
				
					
							fi 
		fi 
 
			
		
	
		
		
			
				
					
						else 
	else 
 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -1129,7 +1134,7 @@ update_background_check() {
 
			
		
	
		
		
			
				
					
						local  lastDownload = $( read_or_default " $UPDATES_DIR /downloaded "  "" ) 
	local  lastDownload = $( read_or_default " $UPDATES_DIR /downloaded "  "" ) 
 
			
		
	
		
		
			
				
					
						local  updateInstalled = $( read_or_default " $UPDATES_DIR /updated "  "" ) 
	local  updateInstalled = $( read_or_default " $UPDATES_DIR /updated "  "" ) 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
						if  [  ! " $lastDownload "  = =  " $updateInstalled "  ] ;  then 
	if  [  ! " $lastDownload "  = =  " $updateInstalled "  ]  &&  [  ! " $lastDownload "  = =  ""  ]  &&  [  ! " $lastDownload "  = =  "error"  ]  ;  then 
 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
							echo  "Update needed" 
		echo  "Update needed" 
 
			
		
	
		
		
			
				
					
							local  lastCalled = $( get_since_last_time "update_needed" ) 
		local  lastCalled = $( get_since_last_time "update_needed" ) 
 
			
		
	
		
		
			
				
					
							if  ( ( lastCalled  = =  -1) )  ||  ( ( lastCalled > UPDATE_MAIL) ) ;  then 
		if  ( ( lastCalled  = =  -1) )  ||  ( ( lastCalled > UPDATE_MAIL) ) ;  then 
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -1168,6 +1173,13 @@ update_if_needed() {
 
			
		
	
		
		
			
				
					
							msgok "Scripts and config files are up to date" 
		msgok "Scripts and config files are up to date" 
 
			
		
	
		
		
			
				
					
						else 
	else 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
							if  [  " $lastDownload "  = =  "error"  ] ;  then 
 
			
		
	
		
		
			
				
					
								msgerr "Download update failed" 
 
			
		
	
		
		
			
				
					
								if  [  $#  -eq 1  ] ;  then 
 
			
		
	
		
		
			
				
					
									okdlg "Aktualizacja niemożliwa"  " Nie można w tej chwili aktualizować narzędzia. ${ TL } Spróbuj ponownie później. ${ NL } Jeśli problem nie ustąpi - sprawdź konfigurację kanału aktualizacji " 
 
			
		
	
		
		
			
				
					
								fi 
 
			
		
	
		
		
			
				
					
							else 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
								local  changed = 0 
			local  changed = 0 
 
			
		
	
		
		
			
				
					
								local  redeploy = 0 
			local  redeploy = 0 
 
			
		
	
		
		
			
				
					
					
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -1268,7 +1280,7 @@ update_if_needed() {
 
			
		
	
		
		
			
				
					
											ohai "Restarting tool" 
						ohai "Restarting tool" 
 
			
		
	
		
		
			
				
					
											exec  " $TOOL_FILE " 
						exec  " $TOOL_FILE " 
 
			
		
	
		
		
			
				
					
										fi 
					fi 
 
			
		
	
		
		
			
				
					
					
 				fi   
			
				
				
			
		
	
		
		
	
		
		
			
				
					
								fi 
			fi 
 
			
		
	
		
		
			
				
					
							fi 
		fi 
 
			
		
	
		
		
			
				
					
						fi 
	fi