mirror of
				https://github.com/optim-enterprises-bv/secureblue.git
				synced 2025-11-04 04:18:01 +00:00 
			
		
		
		
	feat: add MOTD
This commit is contained in:
		
							
								
								
									
										27
									
								
								config/files/usr/libexec/ublue-motd
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								config/files/usr/libexec/ublue-motd
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,27 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Modified from https://github.com/ublue-os/bazzite/blob/main/system_files/desktop/shared/usr/libexec/ublue-motd
 | 
				
			||||||
 | 
					escape() {
 | 
				
			||||||
 | 
						sed 's/[&/\]/\\&/g' <<< "$1"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IMAGE_INFO="/usr/share/ublue-os/image-info.json"
 | 
				
			||||||
 | 
					IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO)
 | 
				
			||||||
 | 
					IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME")
 | 
				
			||||||
 | 
					IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO)
 | 
				
			||||||
 | 
					IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG")
 | 
				
			||||||
 | 
					TIP=""
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					IMAGE_DATE=$(rpm-ostree status --booted | sed -n 's/.*Timestamp: \(.*\)/\1/p')
 | 
				
			||||||
 | 
					IMAGE_DATE_SECONDS=$(date -d "$IMAGE_DATE" +%s)
 | 
				
			||||||
 | 
					CURRENT_SECONDS=$(date +%s)
 | 
				
			||||||
 | 
					DIFFERENCE=$((CURRENT_SECONDS - IMAGE_DATE_SECONDS))
 | 
				
			||||||
 | 
					MONTH=$((30 * 24 * 60 * 60))
 | 
				
			||||||
 | 
					if [ "$DIFFERENCE" -ge "$MONTH" ]; then
 | 
				
			||||||
 | 
					    TIP='#  Your current image is over 1 month old, run `ujust update`'
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TIP_ESCAPED=$(escape "$TIP")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					TIP_OUTPUT=sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/secureblue.txt | tr '~' '\n'
 | 
				
			||||||
 | 
					echo $TIP_OUTPUT
 | 
				
			||||||
							
								
								
									
										11
									
								
								config/files/usr/share/ublue-os/motd/secureblue.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								config/files/usr/share/ublue-os/motd/secureblue.txt
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,11 @@
 | 
				
			|||||||
 | 
					Welcome to secureblue!
 | 
				
			||||||
 | 
					Your image is: %IMAGE_NAME%:%IMAGE_TAG%
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Commands:
 | 
				
			||||||
 | 
					| `ujust`  | List all available commands |
 | 
				
			||||||
 | 
					| `ujust toggle-user-motd` | Toggle this banner on/off |
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					%TIP%
 | 
				
			||||||
 | 
					To report an issue: https://github.com/secureblue/secureblue/issues
 | 
				
			||||||
 | 
					FAQ: https://github.com/secureblue/secureblue/blob/live/FAQ.md
 | 
				
			||||||
 | 
					Discord: https://discord.gg/qMTv5cKfbF
 | 
				
			||||||
		Reference in New Issue
	
	Block a user