-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathcommon.sh
More file actions
80 lines (72 loc) · 2.48 KB
/
common.sh
File metadata and controls
80 lines (72 loc) · 2.48 KB
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
#!/bin/bash
do_exit() {
if [ $REBOOT -eq 1 ]; then
whiptail --backtitle "$( window_title )" --msgbox \
"You need to reboot your server for the changes to take effect" 0 0
fi
exit 0
}
# $1 is the URL
# $2 is the name of what is downloading to show on the window
# $3 is the output file name
dlf() {
wget "$1" 2>&1 -O $3 | stdbuf -o0 awk '/[.] +[0-9][0-9]?[0-9]?%/ { print substr($0,63,3) }' | whiptail --gauge "$2" 0 0 100
}
# $1 is the URL
# $2 is the name of what is downloading to show on the window
# $3 is the output file name
dlf_fast() {
axel -n 5 "$1" -o $3 2>&1 | stdbuf -o0 awk '/[0-9][0-9]?%+/ { print substr($0,2,3) }' | whiptail --backtitle "xTuple Server v$_REV" --gauge "$2" 0 0 100
}
# $1 is the msg
msgbox() {
whiptail --backtitle "$( window_title )" --msgbox "$1" 0 0 0
}
# $1 is the product
latest_version() {
echo `curl -s http://files.xtuple.org/latest_$1`
}
window_title() {
if [ -z $PGHOST ] && [ -z $PGPORT ] && [ -z $PGUSER ] && [ -z $PGPASSWORD ]; then
echo "xTuple Utility v$_REV -=- Current Connection Info: Not Connected"
elif [ ! -z $PGHOST ] && [ ! -z $PGPORT ] && [ ! -z $PGUSER ] && [ -z $PGPASSWORD ]; then
echo "xTuple Utility v$_REV -=- Current Server $PGUSER@$PGHOST:$PGPORT -=- Password Is Not Set"
else
echo "xTuple Utility v$_REV -=- Current Server $PGUSER@$PGHOST:$PGPORT -=- Password Is Set"
fi
}
# $1 is text to display
menu_title() {
cat xtuple.asc
echo "$1"
}
# these are both the same currently, but the structure may change eventually
# as we add more supported distros
install_prereqs() {
case "$DISTRO" in
"ubuntu")
apt-get update && apt-get -y install axel git whiptail unzip bzip2 wget curl postgresql-client-9.3
RET=$?
if [ $RET -eq 1 ]; then
msgbox "Something went wrong installing prerequisites for $DISTRO. Check the output for more info. "
do_exit
fi
;;
"debian")
apt-get update && apt-get -y install axel git whiptail unzip bzip2 wget curl postgresql-client-9.3
RET=$?
if [ $RET -eq 1 ]; then
msgbox "Something went wrong installing prerequisites for $DISTRO. Check the output for more info. "
do_exit
fi
;;
"centos")
echo "Maybe one day we will support CentOS..."
do_exit
;;
*)
echo "Shouldn't reach here! Please report this on GitHub."
exit 0
;;
esac
}