Add checks for the file 'dumpkeys.cache'
This commit adds check for the file 'dumpkeys.cache' because it should be exist in the main directory and in some cases it can't be recreated. Also, this commit contains some enchancements for all other checks and for the functions/*.sh modules. Change-Id: Iaa55921709e0575e924af042f4322b759847d097 Closes-Bug: #1547019
This commit is contained in:
parent
8e1be25492
commit
74374b316c
|
@ -29,12 +29,36 @@ source ./functions/vm.sh
|
||||||
source ./functions/network.sh
|
source ./functions/network.sh
|
||||||
source ./functions/shell.sh
|
source ./functions/shell.sh
|
||||||
|
|
||||||
|
# Check for the 'dumpkeys.cache' file
|
||||||
|
echo -n "Checking for 'dumpkeys.cache'... "
|
||||||
|
if ! [ -f dumpkeys.cache ]; then
|
||||||
|
echo
|
||||||
|
echo
|
||||||
|
echo "The file 'dumpkeys.cache' shouldn't be removed from the main directory!"
|
||||||
|
case "$(uname)" in
|
||||||
|
CYGWIN*)
|
||||||
|
echo "Please restore it from the sources, it can't be recreated on this operating system."
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Please restore it from the sources, or it can recreated using this command:"
|
||||||
|
echo " sudo dumpkeys --keys-only > dumpkeys.cache"
|
||||||
|
echo "The 'dumpkeys' and 'sudo' should be installed first using your package manager."
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
echo "Aborting."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
fi
|
||||||
|
|
||||||
# Check for procps package
|
# Check for procps package
|
||||||
if [ "$(execute uname -s | cut -c1-6)" = "CYGWIN" ]; then
|
if [ "$(execute uname -s | cut -c1-6)" = "CYGWIN" ]; then
|
||||||
echo -n "Checking for 'free'... "
|
echo -n "Checking for 'free'... "
|
||||||
execute type free >/dev/null 2>&1
|
execute type free >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "\"free\" is not available in the path, but it's required. Please install the \"procps\" package. Aborting."
|
echo
|
||||||
|
echo
|
||||||
|
echo "'free' is not available in the path, but it's required. Please install the 'procps' package. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
@ -45,7 +69,9 @@ fi
|
||||||
echo -n "Checking for 'expect'... "
|
echo -n "Checking for 'expect'... "
|
||||||
execute type expect >/dev/null 2>&1
|
execute type expect >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "\"expect\" is not available in the path, but it's required. Please install Tcl \"expect\" package. Aborting."
|
echo
|
||||||
|
echo
|
||||||
|
echo "'expect' is not available in the path, but it's required. Please install Tcl 'expect' package. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
@ -55,17 +81,21 @@ fi
|
||||||
echo -n "Checking for 'xxd'... "
|
echo -n "Checking for 'xxd'... "
|
||||||
execute type xxd >/dev/null 2>&1
|
execute type xxd >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "\"xxd\" is not available in the path, but it's required. Please install the \"xxd\" package. Aborting."
|
echo
|
||||||
|
echo
|
||||||
|
echo "'xxd' is not available in the path, but it's required. Please install the 'xxd' package. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "OK"
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check for VirtualBox
|
# Check for VirtualBox
|
||||||
echo -n "Checking for \"VBoxManage\"... "
|
echo -n "Checking for 'VBoxManage'... "
|
||||||
execute type VBoxManage >/dev/null 2>&1
|
execute type VBoxManage >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
echo "\"VBoxManage\" is not available in the path, but it's required. Likely, VirtualBox is not installed. Aborting."
|
echo
|
||||||
|
echo
|
||||||
|
echo "'VBoxManage' is not available in the path, but it's required. Likely, VirtualBox is not installed. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "OK"
|
echo "OK"
|
||||||
|
@ -75,9 +105,13 @@ fi
|
||||||
echo -n "Checking for VirtualBox Extension Pack... "
|
echo -n "Checking for VirtualBox Extension Pack... "
|
||||||
extpacks=`execute VBoxManage list extpacks | grep 'Usable' | grep 'true' | wc -l`
|
extpacks=`execute VBoxManage list extpacks | grep 'Usable' | grep 'true' | wc -l`
|
||||||
if [ "$extpacks" -le 0 ]; then
|
if [ "$extpacks" -le 0 ]; then
|
||||||
echo >&2 "VirtualBox Extension Pack is not installed. Please, download and install it from the official VirtualBox web site at https://www.virtualbox.org/wiki/Downloads"; exit 1;
|
echo
|
||||||
|
echo
|
||||||
|
echo "VirtualBox Extension Pack is not installed. Please, download and install it from the official VirtualBox web site at https://www.virtualbox.org/wiki/Downloads"
|
||||||
|
exit 1;
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
fi
|
fi
|
||||||
echo "OK"
|
|
||||||
|
|
||||||
# execute some checks only in the 'launch' mode
|
# execute some checks only in the 'launch' mode
|
||||||
if [ $1 == "launch" ]; then
|
if [ $1 == "launch" ]; then
|
||||||
|
@ -103,11 +137,14 @@ fi
|
||||||
# Check for ISO image to be available
|
# Check for ISO image to be available
|
||||||
echo -n "Checking for Mirantis OpenStack ISO image... "
|
echo -n "Checking for Mirantis OpenStack ISO image... "
|
||||||
if [ -z $iso_path ]; then
|
if [ -z $iso_path ]; then
|
||||||
echo "Mirantis OpenStack image is not found. Please download it from software.mirantis.com and put under the 'iso' directory."
|
echo
|
||||||
exit 1
|
echo
|
||||||
|
echo "Mirantis OpenStack image is not found. Please download it from software.mirantis.com and put under the 'iso' directory."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "OK"
|
||||||
|
echo "Going to use Mirantis OpenStack ISO file: $iso_path"
|
||||||
fi
|
fi
|
||||||
echo "OK"
|
|
||||||
echo "Going to use Mirantis OpenStack ISO file $iso_path"
|
|
||||||
|
|
||||||
# Copy ISO to host
|
# Copy ISO to host
|
||||||
copy_if_required $iso_path
|
copy_if_required $iso_path
|
||||||
|
@ -118,6 +155,8 @@ fi # end 'launch' mode check
|
||||||
echo -n "Checking if SSH client installed... "
|
echo -n "Checking if SSH client installed... "
|
||||||
execute type ssh >/dev/null 2>&1
|
execute type ssh >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
|
echo
|
||||||
|
echo
|
||||||
echo "SSH client is not installed. Please install the \"openssh\" package if you run this script under Cygwin. Aborting."
|
echo "SSH client is not installed. Please install the \"openssh\" package if you run this script under Cygwin. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
|
@ -128,6 +167,8 @@ echo -n "Checking if ipconfig or ifconfig installed... "
|
||||||
case "$(execute uname)" in
|
case "$(execute uname)" in
|
||||||
Linux | Darwin)
|
Linux | Darwin)
|
||||||
if ! execute test -x /sbin/ifconfig ; then
|
if ! execute test -x /sbin/ifconfig ; then
|
||||||
|
echo
|
||||||
|
echo
|
||||||
echo "No ifconfig available at /sbin/ifconfig path! This path is hard-coded into VBoxNetAdpCtl utility."
|
echo "No ifconfig available at /sbin/ifconfig path! This path is hard-coded into VBoxNetAdpCtl utility."
|
||||||
echo "Please install ifconfig or create symlink to proper interface configuration utility. Aborting."
|
echo "Please install ifconfig or create symlink to proper interface configuration utility. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -138,11 +179,15 @@ case "$(execute uname)" in
|
||||||
# It uses built-in Windows ipconfig utility instead.
|
# It uses built-in Windows ipconfig utility instead.
|
||||||
execute type ipconfig >/dev/null 2>&1
|
execute type ipconfig >/dev/null 2>&1
|
||||||
if [ $? -eq 1 ]; then
|
if [ $? -eq 1 ]; then
|
||||||
|
echo
|
||||||
|
echo
|
||||||
echo "No ipconfig available in Cygwin environment. Please check you can run ipconfig from Cygwin command prompt. Aborting."
|
echo "No ipconfig available in Cygwin environment. Please check you can run ipconfig from Cygwin command prompt. Aborting."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
echo
|
||||||
|
echo
|
||||||
echo "$(execute uname) is not supported operating system."
|
echo "$(execute uname) is not supported operating system."
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# This file contains the functions to get available memory on host PC
|
# This file contains the functions to get available memory on host PC
|
||||||
|
|
||||||
|
[ "$(basename ${0})" = "memory.sh" ] && exit 1
|
||||||
|
|
||||||
source ./functions/shell.sh
|
source ./functions/shell.sh
|
||||||
|
|
||||||
get_available_memory() {
|
get_available_memory() {
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# This file contains the functions to manage host-only interfaces in the system
|
# This file contains the functions to manage host-only interfaces in the system
|
||||||
|
|
||||||
|
[ "$(basename ${0})" = "network.sh" ] && exit 1
|
||||||
|
|
||||||
source ./functions/shell.sh
|
source ./functions/shell.sh
|
||||||
|
|
||||||
get_hostonly_interfaces() {
|
get_hostonly_interfaces() {
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
# and Fuel became operational, and also enabling outbound network/internet access for this VM through the
|
# and Fuel became operational, and also enabling outbound network/internet access for this VM through the
|
||||||
# host system
|
# host system
|
||||||
|
|
||||||
|
[ "$(basename ${0})" = "product.sh" ] && exit 1
|
||||||
|
|
||||||
source ./functions/shell.sh
|
source ./functions/shell.sh
|
||||||
|
|
||||||
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
|
ssh_options='-oConnectTimeout=5 -oStrictHostKeyChecking=no -oCheckHostIP=no -oUserKnownHostsFile=/dev/null -oRSAAuthentication=no -oPubkeyAuthentication=no'
|
||||||
|
|
|
@ -18,6 +18,8 @@
|
||||||
# Each command might be executed on the local machine or on the remote machine
|
# Each command might be executed on the local machine or on the remote machine
|
||||||
# depending on environment settings
|
# depending on environment settings
|
||||||
|
|
||||||
|
[ "$(basename ${0})" = "shell.sh" ] && exit 1
|
||||||
|
|
||||||
function execute() {
|
function execute() {
|
||||||
# use shell substitution pattern ${parameter/pattern/string}, to escape spaces in arguments.
|
# use shell substitution pattern ${parameter/pattern/string}, to escape spaces in arguments.
|
||||||
if [ -n "$REMOTE_HOST" ]; then
|
if [ -n "$REMOTE_HOST" ]; then
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
|
|
||||||
# This file contains the functions for AT translated set 2 encoder
|
# This file contains the functions for AT translated set 2 encoder
|
||||||
|
|
||||||
type xxd > /dev/null || exit 1
|
[ "$(basename ${0})" = "translate.sh" ] && exit 1
|
||||||
|
|
||||||
if ! test -f dumpkeys.cache; then
|
|
||||||
sudo dumpkeys --keys-only > dumpkeys.cache
|
|
||||||
fi
|
|
||||||
|
|
||||||
# XXX: hardcoded values are generated by:
|
# XXX: hardcoded values are generated by:
|
||||||
#make_break_shift="$(eval echo \$at_table_$(echo -n Shift | xxd -ps))"
|
#make_break_shift="$(eval echo \$at_table_$(echo -n Shift | xxd -ps))"
|
||||||
|
@ -31,69 +27,66 @@ make_shift=36
|
||||||
break_shift=b6
|
break_shift=b6
|
||||||
|
|
||||||
map_set() {
|
map_set() {
|
||||||
# $1 - keycode
|
# $1 - keycode
|
||||||
# $2 - normal value
|
# $2 - normal value
|
||||||
# $3 - shifted value
|
# $3 - shifted value
|
||||||
[ "${2}${3}" = "nulnul" ] && return 1
|
[ "${2}${3}" = "nulnul" ] && return 1
|
||||||
make=$(printf %02x "$1")
|
make=$(printf %02x "$1")
|
||||||
break=$(printf %02x "$(($1 | 128))")
|
break=$(printf %02x "$(($1 | 128))")
|
||||||
eval "at_table_$(echo -n "${3#+}" | xxd -ps)='$make_shift $make $break $break_shift'"
|
eval "at_table_$(echo -n "${3#+}" | xxd -ps)='$make_shift $make $break $break_shift'"
|
||||||
eval "at_table_$(echo -n "${2#+}" | xxd -ps)='$make $break'"
|
eval "at_table_$(echo -n "${2#+}" | xxd -ps)='$make $break'"
|
||||||
}
|
}
|
||||||
|
|
||||||
map_alias() {
|
map_alias() {
|
||||||
# $1,$3,$5,... - names
|
# $1,$3,$5,... - names
|
||||||
# $2,$4,$6,... - aliases
|
# $2,$4,$6,... - aliases
|
||||||
while [ -n "$1" -a -n "$2" ]; do
|
while [ -n "$1" -a -n "$2" ]; do
|
||||||
eval "at_table_$(echo -n "${2#+}" | xxd -ps)=\${at_table_$(echo -n "${1#+}" | xxd -ps)}"
|
eval "at_table_$(echo -n "${2#+}" | xxd -ps)=\${at_table_$(echo -n "${1#+}" | xxd -ps)}"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# at_table_$normal = n
|
# at_table_$normal = n
|
||||||
# at_table_$shifted = n
|
# at_table_$shifted = n
|
||||||
while read keycode n _ normal shifted rest; do
|
while read keycode n _ normal shifted rest; do
|
||||||
[ "$keycode" = "keycode" ] || continue
|
[ "$keycode" = "keycode" ] || continue
|
||||||
map_set "${n}" "${normal}" "${shifted}"
|
map_set "${n}" "${normal}" "${shifted}"
|
||||||
done < dumpkeys.cache
|
done < dumpkeys.cache
|
||||||
|
|
||||||
# Extra mapping
|
# Extra mapping
|
||||||
map_alias \
|
map_alias \
|
||||||
one 1 exclam '!' \
|
one 1 exclam '!' \
|
||||||
two 2 at '@' \
|
two 2 at '@' \
|
||||||
three 3 numbersign '#' \
|
three 3 numbersign '#' \
|
||||||
four 4 dollar '$' \
|
four 4 dollar '$' \
|
||||||
five 5 percent '%' \
|
five 5 percent '%' \
|
||||||
six 6 asciicircum '^' \
|
six 6 asciicircum '^' \
|
||||||
seven 7 ampersand '&' \
|
seven 7 ampersand '&' \
|
||||||
eight 8 asterisk '*' \
|
eight 8 asterisk '*' \
|
||||||
nine 9 parenleft '(' \
|
nine 9 parenleft '(' \
|
||||||
zero 0 parenright ')' \
|
zero 0 parenright ')' \
|
||||||
minus '-' underscore '_' \
|
minus '-' underscore '_' \
|
||||||
equal '=' plus '+'
|
equal '=' plus '+'
|
||||||
|
|
||||||
map_alias \
|
map_alias \
|
||||||
bracketleft '[' braceleft '{' \
|
bracketleft '[' braceleft '{' \
|
||||||
bracketright ']' braceright '}' \
|
bracketright ']' braceright '}' \
|
||||||
semicolon ';' colon ':' \
|
semicolon ';' colon ':' \
|
||||||
apostrophe "'" quotedbl '"' \
|
apostrophe "'" quotedbl '"' \
|
||||||
grave '`' asciitilde '~' \
|
grave '`' asciitilde '~' \
|
||||||
backslash "\\" bar '|' \
|
backslash "\\" bar '|' \
|
||||||
comma ',' less '<' \
|
comma ',' less '<' \
|
||||||
period '.' greater '>' \
|
period '.' greater '>' \
|
||||||
slash '/' question '?' \
|
slash '/' question '?' \
|
||||||
space ' ' Return $'\n'
|
space ' ' Return $'\n'
|
||||||
|
|
||||||
translate() {
|
translate() {
|
||||||
for t in $(echo -n "$*" | xxd -ps | sed -e 's/../& /g'); do
|
for t in $(echo -n "$*" | xxd -ps | sed -e 's/../& /g'); do
|
||||||
n="at_table_$t"
|
n="at_table_$t"
|
||||||
v="${!n}"
|
v="${!n}"
|
||||||
[ -z "$v" ] && echo "$0: unknown char: '$t'." >&2
|
[ -z "$v" ] && echo "$0: unknown char: '$t'." >&2
|
||||||
echo -n " ${v}"
|
echo -n " ${v}"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
[ "$(basename "$0")" = "translate.sh" ] && translate " vmlinuz initrd=initrd.img biosdevname=0 ks=cdrom:/ks.cfg ip=10.20.0.2 gw=10.20.0.1 dns1=10.20.0.1 netmask=255.255.255.0 hostname=fuel.domain.tld showmenu=no
|
|
||||||
"
|
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
# This file contains the functions to manage VMs in through VirtualBox CLI
|
# This file contains the functions to manage VMs in through VirtualBox CLI
|
||||||
|
|
||||||
|
[ "$(basename ${0})" = "vm.sh" ] && exit 1
|
||||||
|
|
||||||
source ./functions/shell.sh
|
source ./functions/shell.sh
|
||||||
|
|
||||||
get_vm_base_path() {
|
get_vm_base_path() {
|
||||||
|
|
Loading…
Reference in New Issue