ovirt-node 2.2.0 release
[ovirt-node.git] / scripts / ovirt-config-kdump
blobf26863c79d6b451f0dbaa44a82f27f4960d59b53
1 #!/bin/bash
3 # Configure kdump
4 # Source functions library
5 . /etc/init.d/functions
6 . /usr/libexec/ovirt-functions
8 trap '__st=$?; stop_log; exit $__st' 0
9 trap 'exit $?' 1 2 13 15
11 warn() { printf '%s\n' "$*" >&2; }
13 check() {
14 if ! is_local_storage_configured; then
15 warn "Configure local storage before configuring kdump."
16 exit 99
18 if ! network_up; then
19 warn "Configure network before configuring kdump."
20 exit 99
24 function write_kdump_config {
25 cat > /etc/kdump.conf <<EOF
26 default reboot
27 net $1
28 EOF
29 ovirt_store_config /etc/kdump.conf
30 return 0
33 function kdump_confirm {
35 local server=$1
36 local server_type=$2
38 printf "\nkdump $server_type Configuration\n"
39 printf "\n$server_type: $server \n\n"
40 if ask_yes_or_no "Confirm these values ([Y]es/[N]o)?"; then
41 write_kdump_config $server
42 if [ $server_type = "SSH" ]; then
43 # /dev/console is occupied by firstboot, need to make /dev/tty available
44 rm -rf /dev/tty
45 ln -s /dev/console /dev/tty
46 service kdump propagate
48 service kdump restart
53 function nfs_config {
54 nfs_server=""
55 printf "\n"
56 read -p "Enter nfs server path (example.redhat.com:/var/crash): " -er
57 test -z "$REPLY" && return 1
58 nfs_server="$REPLY"
59 kdump_confirm $nfs_server NFS
63 function ssh_config {
64 ssh_login=""
65 printf "\n"
66 read -p "Enter ssh user/hostname (root@example.redhat.com): " -er
67 test -z "$REPLY" && return 1
68 ssh_login="$REPLY"
69 kdump_confirm $ssh_login SSH
72 function restore_config {
73 cat > /etc/kdump.conf <<\EOF
74 default reboot
75 ext4 /dev/HostVG/Data
76 path /core
77 EOF
78 ovirt_store_config /etc/kdump.conf
79 service kdump restart
82 NFS="Setup NFS Configuration"
83 SSH="Setup SSH Configuration"
84 RESTORE="Restore Default Configuration"
85 QUIT="Return to the Hypervisor Configuration Menu"
87 if [ "$1" = "AUTO" ]; then
88 if [ -n "$OVIRT_KDUMP_NFS" ]; then
89 write_kdump_config $OVIRT_KDUMP_NFS
91 else
92 check
93 printf "\n\n kdump Configuration\n\n"
94 while true; do
95 PS3="Choose an option: "
96 select option in "$NFS" "$SSH" "$RESTORE" "$QUIT"
99 case $option in
100 $NFS) nfs_config; break;;
101 $SSH) ssh_config; break;;
102 $RESTORE) restore_config; break;;
103 $QUIT) exit;;
104 esac
105 done
107 printf "\n"
108 done