Skip to content

Commit 9b3bd6e

Browse files
Add mechanism for motd management (#89)
Co-authored-by: Joey Turner <Tearran@users.noreply.github.com>
1 parent be55d5c commit 9b3bd6e

2 files changed

Lines changed: 65 additions & 5 deletions

File tree

lib/armbian-configng/config.ng.jobs.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,14 +323,13 @@
323323
},
324324
{
325325
"id": "S23",
326-
"description": "Install alternative kernels",
327-
"prompt": "Switching between kernels might change functionality of your device. \n\nIt might fail to boot!",
328-
"command": [ "switch_kernels" ],
326+
"description": "Adjust welcome screen (motd)",
327+
"command": [ "adjust_motd" ],
329328
"status": "Active",
330329
"doc_link": "",
331330
"src_reference": "",
332-
"author": "Igor Pecovnik",
333-
"condition": ""
331+
"author": "",
332+
"condition": "[ -f /etc/default/armbian-motd ]"
334333
}
335334
]
336335
},

lib/armbian-configng/config.ng.system.sh

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,65 @@ else
225225
sudo service ssh restart
226226
fi
227227
}
228+
229+
module_options+=(
230+
["adjust_motd,author"]="igorpecovnik"
231+
["adjust_motd,ref_link"]=""
232+
["adjust_motd,feature"]="Adjust motd"
233+
["adjust_motd,desc"]="Adjust welcome screen (motd)"
234+
["adjust_motd,example"]=""
235+
["adjust_motd,status"]="Active"
236+
)
237+
#
238+
# @description Toggle message of the day items
239+
#
240+
function adjust_motd
241+
{
242+
243+
# show motd description
244+
motd_desc(){
245+
case $1 in
246+
clear)
247+
echo "Clear screen on login"
248+
;;
249+
header)
250+
echo "Show header with logo"
251+
;;
252+
sysinfo)
253+
echo "Display system information"
254+
;;
255+
tips)
256+
echo "Show Armbian team tips"
257+
;;
258+
commands)
259+
echo "Show recommended commands"
260+
;;
261+
*)
262+
echo "No description"
263+
;;
264+
esac
265+
}
266+
267+
# read status
268+
function motd_status
269+
{
270+
source /etc/default/armbian-motd
271+
if [[ $MOTD_DISABLE == *$1* ]] ; then
272+
echo "OFF"
273+
else
274+
echo "ON"
275+
fi
276+
}
277+
278+
LIST=()
279+
for v in $(grep THIS_SCRIPT= /etc/update-motd.d/* | cut -d"=" -f2 | sed "s/\"//g"); do
280+
LIST+=("$v" "$(motd_desc $v)" "$(motd_status $v)")
281+
done
282+
283+
INLIST=($(grep THIS_SCRIPT= /etc/update-motd.d/* | cut -d"=" -f2 | sed "s/\"//g"))
284+
CHOICES=$(whiptail --separate-output --nocancel --title "Adjust welcome screen" --checklist "" 11 50 5 "${LIST[@]}" 3>&1 1>&2 2>&3)
285+
INSERT=$(echo ${INLIST[@]} ${CHOICES[@]} | tr ' ' '\n' | sort | uniq -u | tr '\n' ' ' | sed 's/ *$//')
286+
# adjust motd config
287+
sed -i "s/^MOTD_DISABLE=.*/MOTD_DISABLE=\"$INSERT\"/g" /etc/default/armbian-motd
288+
228289
}

0 commit comments

Comments
 (0)