-
Notifications
You must be signed in to change notification settings - Fork 1
/
dynmotd-install
executable file
·94 lines (77 loc) · 2.5 KB
/
dynmotd-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Part of raspi-config http://github.com/asb/raspi-config
#
# See LICENSE file for copyright and license details
if [ $(id -u) -ne 0 ]; then
whiptail --msgbox "\
This script needs to be run as root. \
\nPlease use '$ sudo dynmotd-install'" 12 40 1
exit 1
fi
calc_wt_size() {
WT_HEIGHT=12
WT_WIDTH=$(tput cols)
if [ -z "$WT_WIDTH" ] || [ "$WT_WIDTH" -lt 60 ]; then
WT_WIDTH=80
fi
if [ "$WT_WIDTH" -gt 178 ]; then
WT_WIDTH=120
fi
WT_MENU_HEIGHT=$(($WT_HEIGHT-8))
}
do_about() {
whiptail --msgbox "\
This is the installation script for Dynamic-MOTD. \
Select a version to install and this script will\
take care of the rest.\
" 12 64 1
}
install_cpp() {
wget -O /usr/local/bin/dynmotd-cpp https://github.com/Zeklandia/Dynamic-MOTD-CPP/raw/master/src/dynamic_motd_cpp
ln -s /usr/local/bin/dynmotd-cpp /usr/bin/dynmotd-cpp
chmod +x /usr/local/bin/dynmotd-cpp
whiptail --msgbox "Installation of Dynamic-MOTD-C++ Complete!" 8 32 2
}
install_java() {
wget -O /usr/local/bin/dynmotd-java.jar https://raw.github.com/Zeklandia/Dynamic-MOTD-Java/master/src/dynmotd-java.jar
wget -O /usr/local/bin/dynmotd-java https://raw.github.com/Zeklandia/Dynamic-MOTD-Java/master/src/dynmotd-java
ln -s /usr/local/bin/dynmotd-java /usr/bin/dynmotd-java
chmod +x /usr/local/bin/dynmotd-java
chmod +x /usr/local/bin/dynmotd-java.jar
whiptail --msgbox "Installation of Dynamic-MOTD-Java Complete!" 8 32 2
}
install_shell() {
wget -O /usr/local/bin/dynmotd-shell https://raw.github.com/Zeklandia/Dynamic-MOTD-Shell/master/dynmotd-shell
ln -s /usr/local/bin/dynmotd-shell /usr/bin/dynmotd-shell
chmod +x /usr/local/bin/dynmotd-shell
whiptail --msgbox "Installation of Dynamic-MOTD-Shell Complete!" 8 32 2
}
do_finish() {
exit 0
}
#
# Interactive use loop
#
calc_wt_size
while true; do
FUN=$(whiptail --title "Dynamic-MOTD Installation Script" --menu "Installation Types" $WT_HEIGHT $WT_WIDTH $WT_MENU_HEIGHT --cancel-button Done --ok-button Install \
"1 C++" "A compiled C++ binary" \
"2 Java" "A Java .jar file" \
"3 Shell" "A Shell script" \
"4 About This Script" "Information about this installation script" \
3>&1 1>&2 2>&3)
RET=$?
if [ $RET -eq 1 ]; then
do_finish
elif [ $RET -eq 0 ]; then
case "$FUN" in
1\ *) install_cpp ;;
2\ *) install_java ;;
3\ *) install_shell ;;
4\ *) do_about ;;
*) whiptail --msgbox "Whoops! Report this as an issue" 8 48 1 ;;
esac || whiptail --msgbox "There was an error installing $FUN" 8 48 1
else
exit 1
fi
done