Files
a2server/scripts/a2server-7-console.txt
T
T. Joseph Carter 530b8d57f5 Clean the main scripts a bit
Ivan writes pretty dense scripts in some ways, but not others.  Mostly
he likes to collapse statements to a single line and using && and || in
place of if constructs.  Reduces file size and theoretically speeds
execution, but it makes community development tougher and the speed
gains are questionable.

I've begun removing multiple successive writes to a single file such as
those using tee as a means to write files as root.  Clean up enough of
those and you will have a noticable performance impact, although again
there's no evidence there are enough of them here to see one.

Removed a few dead/commented code blocks and restructured a couple of
conditionals to make the no-action condition the else case.

Finally, bumped the version.  This isn't all that'll go into 1.5.1 but
it's a start.
2016-10-27 00:55:16 -07:00

38 lines
1.2 KiB
Plaintext
Executable File

#! /bin/bash
# vim: set tabstop=4 shiftwidth=4 noexpandtab filetype=sh:
# This script helps when running on the Linux console within a VirtualBox VM.
echo
userPw=$(sudo grep "^$USER" /etc/shadow | cut -f 2 -d ':')
isApple2Pw=
if [[ $userPw == "$(echo 'apple2' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]]; then
isApple2Pw=1
fi
isRaspberryPw=
if [[ $userPw == "$(echo 'raspberry' | perl -e '$_ = <STDIN>; chomp; print crypt($_, $ARGV[0])' "${userPw%"${userPw#\$*\$*\$}"}")" ]]; then
isRaspberryPw=1
fi
password="your password"
[[ $isApple2Pw ]] && password="'apple2'"
[[ $isRaspberryPw ]] && password="'raspberry'"
isDebian=
if lsb_release -a 2> /dev/null | grep -q 'Distributor ID:.Debian'; then
if [[ $(cut -d . -f 1 < /etc/debian_version) -ge "7" ]]; then
isDebian=1
fi
fi
if [[ $isDebian ]]; then
if lspci 2>/dev/null | grep -q VirtualBox; then
echo "A2SERVER: Disabling VirtualBox console screen blanking..."
sudo sed -i 's/^BLANK_DPMS=off/BLANK_DPMS=on/' /etc/kbd/config
sudo sed -i 's/^BLANK_TIME=[^0].$/BLANK_TIME=0/' /etc/kbd/config
sudo /etc/init.d/kbd restart &> /dev/null
sudo /etc/init.d/console-setup restart &> /dev/null
fi
fi