Dre4m Shell
Server IP : 85.214.239.14  /  Your IP : 18.191.84.179
Web Server : Apache/2.4.62 (Debian)
System : Linux h2886529.stratoserver.net 4.9.0 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.18
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
MySQL : OFF  |  cURL : OFF  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /usr/sbin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/sbin/install-keymap
#!/bin/sh

# Copyright (c) 1999-2001 Yann Dirson <dirson@debian.org>


CONFDIR=/etc/console
CONFFILEROOT=boottime
KMAPEXT=kmap

# Set up i18n if possible
TEXTDOMAIN=install-keymap
export TEXTDOMAIN

if which gettext >/dev/null
then
   GETTEXT="gettext -e -s"
else
   GETTEXT="echo -e"
fi

if [ $# != 1 ]
then
    $GETTEXT >&2 "Usage: install-keymap [ keymap_file | NONE | KERNEL ]"
    exit 1
fi

if [ "$1" =  "--help" ]
then
    $GETTEXT "Usage: install-keymap [ keymap_file | NONE | KERNEL ]"
    exit 0
fi
if [ "$1" = "--version" ]
then
   VERSION=`dpkg -l console-common | tail -n 1 | awk '{print $3}' `
   #  This string can not be localized, and it is not worth trying to
   echo "install-keymap: (console-common) " $VERSION
   exit 0
fi

keymap="$1"
if [ "$keymap" = NONE ]
then
    exit 0
fi

CONSOLE_TYPE=`fgconsole 2>/dev/null`
if  [ "$?" != "0" ]
then
   $GETTEXT >&2 "Deferring virtual terminal setup until console accessible."
   exit 0
fi

check_if_serial_console()
{
	if [ $CONSOLE_TYPE = "serial" ] 
	then
	   $GETTEXT >&2 "Warning: cannot install keymap on a serial console.\n deferring until non-serial console present."
	   exit 0
	fi
}

if ! which loadkeys >/dev/null
then
  $GETTEXT >&2 "Warning: no console utilities installed yet.\n deferring keymap setting until either console-tools or kbd is installed."
  exit 0
fi

do_preserving_keymap()
# execute shell command-line preserving the keymap
{
    # save keymap
    TMP=`tempfile`
    if ! dumpkeys >${TMP}; then
    	check_if_serial_console
	$GETTEXT >&2 "Failed to dump keymap!"
	$GETTEXT >&2 "This might be because your console cannot be opened.  Perhaps you don't have\na video card, are connected via the serial console or ssh.\nNot loading keymap!"

         rm -f ${TMP}
         exit 0
    fi

    if ! (eval "$*" && loadkeys -q ${TMP}); then
    	 check_if_serial_console
         $GETTEXT >&2 "Failed to preserve keymap!"
         rm -f ${TMP}
         exit 0
    fi

    rm -f ${TMP}
}

 # Be extra safe
mkdir -p ${CONFDIR}

NEW=`tempfile --suffix .gz`
CONFFILE=${CONFDIR}/${CONFFILEROOT}.${KMAPEXT}.gz
OLD_CONFFILE=${CONFDIR}/${CONFFILEROOT}.old.${KMAPEXT}.gz


backup()
{
    # If symlink, then don't overwrite, just provide new one
    if [ -h ${CONFFILE} ]
    then
	mv $NEW ${CONFFILE}.dpkg
	$GETTEXT >&2 "conffile ${CONFFILE} is a symlink : not overwriting"
	$GETTEXT >&2 "It is recommended that ${CONFFILE} is not a symlink; instead\nedit /etc/console-tools/remap to include any local changes."
	$GETTEXT >&2 "The new keymap has been placed in ${CONFFILE}.dpkg ;\nPlease move it as required."
    fi
    
    # Keep a backup if no backup already exists
    [ -f ${CONFFILE} -a ! -f ${OLD_CONFFILE} ] && 
	mv ${CONFFILE} ${OLD_CONFFILE}
    # Also backup this one, although it should probably not exist
    [ -f ${CONFFILE}%.gz} -a ! -r ${OLD_CONFFILE%.gz} ] && 
	mv ${CONFFILE%.gz} ${OLD_CONFFILE%.gz}
    
    if [ "$keymap" != KERNEL -a -f ${NEW} ]
    then
	mv $NEW $CONFFILE
    fi
    # Make sure perms are correct 
    [ -f ${CONFFILE} ] && chmod -f 644 ${CONFFILE} || true
    [ -f ${OLD_CONFFILE} ] && chmod -f 644 ${OLD_CONFFILE} || true
}

if [ "$keymap" = KERNEL ]
then
    backup
    rm -f ${CONFFILE}
else
    if [ "`dpkg --print-architecture`" = "arm" ] && 
	grep -i '^Hardware.*: \(Acorn-\|RiscStation-\)' /proc/cpuinfo >/dev/null &&
	find /usr/share/keymaps/i386/ -type f -name ${keymap} -o \
		    -name ${keymap}.gz -o -name ${keymap}.kmap.gz
    then
	# we're pretty sure now we were asked to load a PC keymap on a RiscPC
	$GETTEXT >&2 "Notice: doing keycode translation to use PC keymap on RiscPC"
	TRANSLATOR=/usr/share/console/ps2-to-riscpc
    else
	TRANSLATOR=cat
    fi

    # Running the translator at this point is the best way to look for problems, but
    # running it prior to "loadkeys" (where it would belong really) is mostly not possible
    # because of include files and include-like directives.
    # It may turn out that we really need to do keymap-file expansion differently because
    # of this.  Sigh.
    do_preserving_keymap "loadkeys -q $keymap ; dumpkeys | $TRANSLATOR | gzip -9n > $NEW"

    # if diff is available, use it to install only if needed
    if [ -r $CONFFILE ] && which diff >/dev/null
    then
	if diff -q $CONFFILE $NEW >/dev/null
	then
	    rm $NEW
	else
	    backup
	fi
    else
	backup
    fi

    if ! loadkeys -q $CONFFILE; then
        $GETTEXT >&2 "Failed to load keymap!"
    fi
    # Store md5sum. debconf code uses this to track keymaps it has installed,
    # so it doesn't change ones installeed by user. Its compressed, so we
    # don't want to use the usual conffiles mechanism.
    . /usr/share/debconf/confmodule
    MD=`md5sum $CONFFILE | cut -f1 -d' ' `
    db_set console-data/bootmap-md5sum $MD
fi

Anon7 - 2022
AnonSec Team