--- /dev/null
+name: Code Testing
+
+on:
+ push:
+ pull_request:
+ schedule:
+ - cron: '42 1 * * *'
+
+jobs:
+ spellcheck:
+ runs-on: ubuntu-latest
+ name: Run spellcheck
+
+ steps:
+ - name: Checkout source
+ uses: actions/checkout@v2
+
+ - name: Update APT cache
+ run: sudo apt-get update
+
+ - name: Install lintian
+ run: sudo apt-get -y install lintian
+
+ - name: Spellcheck execution
+ run: make spellcheck
+
+ codecheck:
+ runs-on: ubuntu-latest
+ name: Run codecheck
+
+ steps:
+ - name: Checkout source
+ uses: actions/checkout@v2
+
+ - name: Display original shellcheck version
+ run: shellcheck --version
+
+ - name: Update shellcheck to latest stable version
+ run: |
+ wget -qO- https://github.com/koalaman/shellcheck/releases/download/stable/shellcheck-stable.linux.x86_64.tar.xz | tar -xJv
+ sudo cp shellcheck-stable/shellcheck /usr/bin/
+
+ - name: pip install flake8, isort + black
+ run: pip3 install -U flake8 isort black
+
+ - name: Display current shellcheck version
+ run: shellcheck --version
+
+ - name: Display current flake8 version
+ run: flake8 --version
+
+ - name: Display current isort version
+ run: isort --version
+
+ - name: Display current black version
+ run: black --version
+
+ - name: Codecheck execution
+ run: make --keep-going codecheck
--- /dev/null
+.DEFAULT_GOAL:=help
+
+help: ## Display this help
+ @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-10s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
+
+allcheck: codecheck spellcheck ## Run codecheck and spellcheck
+
+codecheck: shellcheck pythoncheck ## Run shellcheck and pythoncheck
+
+.ONESHELL:
+shellcheck: ## Run shellcheck
+ @RETURN=0
+ @for shellfile in $$(ls usr_bin/* usr_sbin/* usr_share/*); do
+ @ [ "$${shellfile}" = "usr_bin/iimage" ] && continue
+ @ [ "$${shellfile}" = "usr_sbin/make_chroot_jail" ] && continue
+ @ file "$${shellfile}" | grep -q shell && (shellcheck -x "$${shellfile}" || RETURN=1)
+ @done
+ @exit $${RETURN}
+
+.ONESHELL:
+pythoncheck: ## Run pythoncheck (flakecheck, isortcheck + blackcheck)
+ @RETURN=0
+ @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+ @ if head -1 "$${pythonfile}" | grep -q "python"; then
+ @ flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1
+ @ isort --check "$${pythonfile}" || RETURN=1
+ @ black --check "$${pythonfile}" || RETURN=1
+ @ fi
+ @done
+ @exit $${RETURN}
+
+.ONESHELL:
+flakecheck: ## Run flake8 only
+ @RETURN=0
+ @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+ @ if head -1 "$${pythonfile}" | grep -q "python"; then
+ @ flake8 --max-line-length 88 "$${pythonfile}" || RETURN=1
+ @ fi
+ @done
+ @exit $${RETURN}
+
+.ONESHELL:
+isortcheck: ## Run isort --check only
+ @RETURN=0
+ @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+ @ if head -1 "$${pythonfile}" | grep -q "python"; then
+ @ isort --check "$${pythonfile}" || RETURN=1
+ @ fi
+ @done
+ @exit $${RETURN}
+
+.ONESHELL:
+blackcheck: ## Run black --check only
+ @RETURN=0
+ @for pythonfile in usr_bin/* usr_sbin/* usr_share/*; do
+ @ if head -1 "$${pythonfile}" | grep -q "python"; then
+ @ black --check "$${pythonfile}" || RETURN=1
+ @ fi
+ @done
+ @exit $${RETURN}
+
+.ONESHELL:
+spellcheck: ## Run spellcheck
+ @OUTPUT="$$(spellintian manpages/*)"
+ @echo $$OUTPUT
+ @if [ -n "$$OUTPUT" ]; then
+ @ false
+ @fi
align
dpkg_not_running
-vmware-detect
grml-runtty
-PROGS = vmware-detect dpkg_not_running grml-runtty
+PROGS = dpkg_not_running grml-runtty
#ifndef CFLAGS
CFLAGS = -O2 -Wall -s
all: $(PROGS)
-vmware-detect: vmware-detect.c
- diet $(CC) $(CFLAGS) -o $@ $^
-
dpkg_not_running: dpkg_not_running.c
diet $(CC) $(CFLAGS) -o $@ $^
+++ /dev/null
-/* Filename: vmware-detect.c
-* Purpose: Detect if running inside vmware
-* Authors: grml-team (grml.org), (c) Michael Gebetsroither <gebi@grml.org>
-* Bug-Reports: see http://grml.org/bugs/
-* License: This file is licensed under the GPL v2.
-*******************************************************************************/
-// return 0 if running inside vmware, 1 otherwise
-
-#include "string.h"
-#include "unistd.h"
-#include "stdio.h"
-#include "stdlib.h"
-#include "signal.h"
-
-#define WRITE(x) write(1, x, strlen(x))
-#define DWRITE(x) do{ \
- if(debug) { \
- WRITE(x); \
- } \
-} while(0);
-#define FALSE 0
-#define TRUE !FALSE
-
-/* doc:
- * vmware IO backdoor: http://chitchat.at.infoseek.co.jp/vmware/backdoor.html
- * http://www.honeynet.org/papers/bots/botnet-code.html
- * http://www.codegurus.be/codegurus/Programming/virtualpc&vmware_en.htm
- */
-
-// from libowfat {{{
-static inline char tohex(char c) {
- return c>=10?c-10+'a':c+'0';
-}
-
-unsigned int fmt_xlong(char *dest,unsigned long i) {
- register unsigned long len,tmp;
- /* first count the number of bytes needed */
- for (len=1, tmp=i; tmp>15; ++len) tmp>>=4;
- if (dest)
- for (tmp=i, dest+=len; ; ) {
- *--dest = tohex(tmp&15);
- if (!(tmp>>=4)) break;
- }
- return len;
-}
-// }}}
-
-void printIdtr(const unsigned char* idtr, unsigned size)
-{
- unsigned i;
- for(i=0; i<size; ++i) {
- char out[4] = {0};
- fmt_xlong(out, idtr[i]);
- if(strlen(out) == 1)
- WRITE("0");
- WRITE(out);
- }
- WRITE("\n");
-}
-
-// i386 and x86-64 {{{
-#if defined (__i386__) || defined (__x86_64__)
-int checkVmware(const int debug)
-{
- unsigned char idtr[10] = {0};
- asm("sidt %0" : "=m" (idtr));
- if(debug)
- printIdtr(idtr, sizeof(idtr));
- // should normally be the case on amd64, but does not work
- //return (0xff==idtr[9]) ? 1 : 0;
- return (0xff==idtr[5]) ? 1 : 0;
-}
-int checkVmwareIO()
-{
- unsigned int vmaj, vmin, magic, dout = 11;
- __asm__ __volatile__(
- "mov $0x564D5868, %%eax; /* magic number */"
- "mov $0x3c6cf712, %%ebx; /* random number */"
- "mov $0x0000000A, %%ecx; /* specifies command */"
- "mov $0x5658, %%edx; /* VMware I/O port */"
- "in %%dx, %%eax;"
- "mov %%eax, %0;"
- "mov %%ebx, %1;"
- "mov %%ecx, %2;"
- "mov %%edx, %3;"
- : "=r"(vmaj), "=r"(magic), "=r"(vmin), "=r"(dout));
-#ifdef DEBUG
- fprintf(stderr, "version: major=%x, minor=%x, magic=%x, dout=%x\n",
- vmaj, vmin, magic, dout);
-#endif
- return (0x564D5868 == magic) ? 1 : 0;
-}
-// }}}
-
-// others {{{
-#else
-// vmware runs only on the archs above
-int checkVmware(const int) { return 0; }
-int checkVmwareIO() { return 0; }
-#endif
-// }}}
-
-static int Killed = FALSE;
-
-// returns 0 if running inside vmware, 1 otherwise
-int main(int argc, char* argv[]) {
- int debug = FALSE;
- if(argc == 2 && !strcmp(argv[1], "--debug"))
- debug = TRUE;
-
- int a, b;
- // known to be false positives
- a = checkVmware(debug);
- DWRITE("idt-check: ")
- if(!a) {
- DWRITE("false\n");
- if(!debug)
- return EXIT_FAILURE;
- } else
- DWRITE("true\n");
-
- // never returns if not running under vmware
- void dummy() { Killed=TRUE; DWRITE("false\n"); exit(1); }
- signal(SIGSEGV, dummy);
- DWRITE("ioport-check: ");
- b = checkVmwareIO();
- if(b) {
- DWRITE("true\n");
- return EXIT_SUCCESS;
- } else {
- if(!Killed) {
- // check unusable or not implemented
- DWRITE("false\n");
- DWRITE("Check not implemented, yet!\n");
- return a ? EXIT_SUCCESS : EXIT_FAILURE;
- } else {
- // never reached
- WRITE("Error: IO check hasn't killed the program but no vmware found either!\n");
- return EXIT_FAILURE;
- }
- }
-}
-// vim: foldmethod=marker
+grml-scripts (2.13.0) unstable; urgency=medium
+
+ * [0c1cd5d] Drop broken and deprecated vmware-detect.
+ Thanks to AndrĂ¡s Korn
+
+ -- Michael Prokop <mika@grml.org> Wed, 06 Sep 2023 17:24:49 +0200
+
+grml-scripts (2.12.2) unstable; urgency=medium
+
+ [ Michael Schierl ]
+ * [099f921] Fix `grml2ram` when booted via `loopback.cfg`
+
+ -- Michael Prokop <mika@grml.org> Fri, 03 Feb 2023 17:26:26 +0100
+
+grml-scripts (2.12.1) unstable; urgency=medium
+
+ [ Darshaka Pathirana ]
+ * [b382566] grml-resolution: Quick 'n dirty xrandr output parser fix
+
+ -- Michael Prokop <mika@grml.org> Mon, 28 Nov 2022 08:35:17 +0100
+
+grml-scripts (2.12.0) unstable; urgency=medium
+
+ [ Darshaka Pathirana ]
+ * [570d959] Set SHELL variable in run-welcome + run-screen
+
+ -- Michael Prokop <mika@grml.org> Fri, 25 Nov 2022 09:50:44 +0100
+
+grml-scripts (2.11.2) unstable; urgency=medium
+
+ * [454a3e5] iimage: replace egrep usage with grep -E
+
+ -- Michael Prokop <mika@grml.org> Fri, 11 Nov 2022 17:01:40 +0100
+
+grml-scripts (2.11.1) unstable; urgency=medium
+
+ * [40ec66c] Drop debian/compat and switch to debhelper-compat approach
+ * [3b7f948] grml_chroot: fix broken mount argument handling
+
+ -- Michael Prokop <mika@grml.org> Tue, 07 Jun 2022 15:59:26 +0200
+
+grml-scripts (2.11.0) unstable; urgency=medium
+
+ [ Darshaka Pathirana ]
+ * [cb8ed97] Add Code testing workflow
+ * [e41ddb1] Makefile: Do not shellcheck iimage
+ * [584376f] Makefile: Do not shellcheck make_chroot_jail
+ * [02a237b] Makefile: return error if a check fails
+ * [95f1a38] grml-swapon.8: Fix spelling (via spellintian)
+ * [a4b7aa6] grepedit/notifyd.py: Convert to Python 3
+ * Many shellcheck related changes
+
+ -- Michael Prokop <mika@grml.org> Fri, 06 May 2022 14:06:47 +0200
+
+grml-scripts (2.10.0) unstable; urgency=medium
+
+ * [7bbfe54] grml-chroot: support efivarfs in EFI environments
+
+ -- Michael Prokop <mika@grml.org> Fri, 09 Jul 2021 09:15:50 +0200
+
+grml-scripts (2.9.1) unstable; urgency=medium
+
+ * [749ee8e] grml-info: drop support for deprecated gdialog and prefer
+ zenity over Xdialog
+ * [09e5d68] grml-lock: drop gdialog usage and don't wrap text in zenity
+
+ -- Michael Prokop <mika@grml.org> Sun, 19 Jul 2020 18:09:17 +0200
+
+grml-scripts (2.9.0) unstable; urgency=medium
+
+ * [34819b8] grml2ram: switch default mount point from
+ /lib/live/mount/medium to /run/live/medium
+
+ -- Michael Prokop <mika@grml.org> Thu, 21 Mar 2019 12:25:51 +0100
+
grml-scripts (2.8.4) unstable; urgency=medium
* [74367b9] grml-chroot: bind-mount /run/udev in target system as
Priority: optional
Maintainer: Michael Prokop <mika@grml.org>
Build-Depends: asciidoc,
- debhelper (>= 10~),
+ debhelper-compat (= 12),
dietlibc-dev,
docbook-xsl,
xsltproc
grml-scripts: script-with-language-extension usr/bin/notifyd.py
-grml-scripts: statically-linked-binary usr/bin/vmware-detect
grml-scripts: statically-linked-binary usr/sbin/dpkg_not_running
cp -a usr_bin/* debian/grml-scripts/usr/bin/
cp -a usr_sbin/* debian/grml-scripts/usr/sbin/
cp -a usr_share/* debian/grml-scripts/usr/share/grml-scripts/
- install -m 755 compile/vmware-detect debian/grml-scripts/usr/bin/vmware-detect
install -m 755 compile/dpkg_not_running debian/grml-scripts/usr/sbin/dpkg_not_running
install -m 755 compile/grml-runtty debian/grml-scripts/sbin/grml-runtty
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/pong.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/soundtest.1.gz \
/usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/unblacklist.1.gz \
- /usr/share/man/man1/grml-scripts.1.gz /usr/share/man/man1/vmware-detect.1.gz
+
dh_strip
dh_compress
mkdir -p $(CURDIR)/debian/grml-scripts/usr/share/lintian/overrides/
grml-swapon is a small script for enabling swap partitions found in /etc/fstab.
Starting with grml 0.9 booting the live-cd system does not activate swap
-parititions by default anymore. It is possible to force usage of swap partitions
+partitions by default anymore. It is possible to force usage of swap partitions
via booting with the bootoption "swap". In case you forgot to use this
bootoption but want to use swap partition(s) anyway you could do that by running
"swapon \-a". But the command "swapon" does not take of suspend signatures,
#!/usr/bin/python
-## Copyright 2005 Drew Perttula
-
-## This program is free software; you can redistribute it and/or modify
-## it under the terms of the GNU General Public License as published by
-## the Free Software Foundation; either version 2 of the License, or
-## (at your option) any later version.
-
-## This program is distributed in the hope that it will be useful,
-## but WITHOUT ANY WARRANTY; without even the implied warranty of
-## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-## GNU General Public License for more details.
-
-## You should have received a copy of the GNU General Public License
-## along with this program; if not, write to the Free Software
-## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+# Copyright 2005 Drew Perttula
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""sometimes we grep for something in a bunch of files, and then we
want to make edits to the lines that were returned from the grep. It's
"""
-import tempfile, sys, os, re
+import os
+import re
+import sys
+import tempfile
+
from sets import Set
+
def grep_parse(filename):
"""parse grep output lines in given file into a dict of
(filename, lineno) : text"""
for line in open(filename):
if line == "--\n":
continue
- m = re.match(r"(?P<filename>.*?)(?P<sep>[-:])(?P<lineno>\d+)(?P=sep)(?P<line>.*\n)$", line)
+ m = re.match(
+ r"(?P<filename>.*?)(?P<sep>[-:])(?P<lineno>\d+)(?P=sep)(?P<line>.*\n)$",
+ line,
+ )
if m is None:
- print "couldn't parse grep result line %r" % line
+ print("couldn't parse grep result line %r" % line)
continue
- filename, lineno, text = (m.group('filename'), int(m.group('lineno')),
- m.group('line'))
- if (filename,lineno) in parse:
- raise ValueError("multiple results found for %s:%s" %
- (filename, lineno))
+ filename, lineno, text = (
+ m.group("filename"),
+ int(m.group("lineno")),
+ m.group("line"),
+ )
+ if (filename, lineno) in parse:
+ raise ValueError("multiple results found for %s:%s" % (filename, lineno))
parse[(filename, lineno)] = text
return parse
+
options = {}
passthru_args = []
for arg in sys.argv[1:]:
if arg == "--sort-text":
- options['sort-text'] = True
+ options["sort-text"] = True
continue
passthru_args.append(arg)
tf = tempfile.NamedTemporaryFile(prefix="grepedit_")
tf.close()
-cmd = ("grep --with-filename --line-number --binary-files=without-match %s > %s" %
- (" ".join(['"%s"' % s.replace("\\","\\\\").replace('"','\\"')
- for s in passthru_args]),tf.name))
+cmd = "grep --with-filename --line-number --binary-files=without-match %s > %s" % (
+ " ".join(
+ ['"%s"' % s.replace("\\", "\\\\").replace('"', '\\"') for s in passthru_args]
+ ),
+ tf.name,
+)
os.system(cmd)
originals = grep_parse(tf.name)
-if options.get('sort-text', False):
- orig = [(v,k) for k,v in originals.items()]
+if options.get("sort-text", False):
+ orig = [(v, k) for k, v in list(originals.items())]
orig.sort()
f = open(tf.name, "w")
- for text, (filename,lineno) in orig:
+ for text, (filename, lineno) in orig:
f.write("%s:%s:%s" % (filename, lineno, text))
f.close()
corrections = grep_parse(tf.name)
-files = Set([filename for filename,lineno in corrections.keys()])
+files = Set([filename for filename, lineno in list(corrections.keys())])
for orig_filename in files:
(copy_fd, copy_filename) = tempfile.mkstemp(
dir=os.path.dirname(orig_filename),
- prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename))
+ prefix="_%s_tmp_grepedit" % os.path.basename(orig_filename),
+ )
any_changes = False
- for lineno,line in enumerate(open(orig_filename)):
- lineno = lineno + 1 # grep is 1-based
- key = orig_filename,lineno
+ for lineno, line in enumerate(open(orig_filename)):
+ lineno = lineno + 1 # grep is 1-based
+ key = orig_filename, lineno
if key in corrections:
if line != originals[key]:
- print "%s:%s has changed since the grep command ran- not modifying this line" % key
- print repr(line)
- print repr(originals[key])
+ print(
+ "%s:%s has changed since the grep command ran- "
+ "not modifying this line" % key
+ )
+ print(repr(line))
+ print(repr(originals[key]))
elif corrections[key] == line:
pass
else:
- print "%s:%s substituting new line" % key
+ print("%s:%s substituting new line" % key)
line = corrections[key]
any_changes = True
os.write(copy_fd, line)
if any_changes:
os.rename(copy_filename, orig_filename)
else:
- print "no changes made in file %s" % orig_filename
+ print("no changes made in file %s" % orig_filename)
os.unlink(copy_filename)
-
-
# License: This file is licensed under the GPL v2 or any later version.
################################################################################
+PN=$(basename "$0")
+
usage() {
- printf "Usage: $0 <program> [<arguments>]
+ printf "Usage: %s <program> [<arguments>]
Available options:
-h | --help display this usage information
-p <program> check specified argument instead of default args, like:
- $(basename $0) -p aumix xterm -T aumix -e aumix
-"
+ %s -p aumix xterm -T aumix -e aumix\n" "${PN}" "${PN}"
}
is_installed() {
fi
}
-if [ -z "$1" -o "$1" = '-h' -o "$1" = '--help' ] ; then
+if [ -z "$1" ] || [ "$1" = '-h' ] || [ "$1" = '--help' ] ; then
usage
exit 1
fi
You can search for ${PROG} executing:
-apt-get update && apt-cache search $(basename ${PROG})
+apt-get update && apt-cache search $(basename "${PROG}")
"
exit 1
firefox $PAGE
elif check4progs x-www-browser &>/dev/null ; then
x-www-browser $PAGE
+ elif check4progs zenity &>/dev/null ; then
+ zenity --no-wrap --error --text="Sorry, no usable X browser (dillo, xlinks2, firefox,...) found."
+ exit 1
elif check4progs Xdialog &>/dev/null ; then
Xdialog --msgbox "Sorry, no usable X browser (dillo, xlinks2, firefox,...) found." 0 0
exit 1
- elif check4progs gdialog &>/dev/null ; then
- gdialog --msgbox "Sorry, no usable X browser (dillo, xlinks2, firefox,...) found." 0 0
- exit 1
- elif check4progs zenity &>/dev/null ; then
- zenity --info --text="Sorry, no usable X browser (dillo, xlinks2, firefox,...) found."
- exit 1
fi
else # no X:
# do we have a real console?
################################################################################
CONFFILE=/etc/default/keyboard
-PN="$(basename $0)"
+PN="$(basename "$0")"
usage(){
- echo "Usage: $0 <language>"
+ echo "Usage: ${PN} <language>"
echo "supported values: at, ch, de, dvorak, es, fr, it, jp, us"
}
LANGUAGE="$1"
+# shellcheck disable=SC1091
. /etc/grml/language-functions
if [ -n "$XKEYBOARD" ] ; then
# License: This file is licensed under the GPL v2.
################################################################################
-PN="$(basename $0)"
+PN="$(basename "$0")"
[ -n "$USER" ] || USER=grml
fi
if [ -r /etc/grml/script-functions ] ; then
+ # shellcheck disable=SC1091
. /etc/grml/script-functions
check4progs physlock sudo chpasswd dialog || { echo "Sorry, necessary tools missing - can not continue. Exiting.">&2 ; exit 1 ; }
fi
DIALOG='dialog'
PWD_CMD="dialog --stdout --title $PN --passwordbox"
-# only if using X and gdialog + zenity are available use graphical frontend
-if [ -n "$DISPLAY" ] && [ -x "$(which gdialog)" ] && [ -x "$(which zenity)" ] ; then
- DIALOG='gdialog'
+GUI=false
+# only when using X and zenity is available use graphical frontend
+if [ -n "${DISPLAY}" ] && [ -x "$(command -v zenity)" ] ; then
+ DIALOG='zenity'
PWD_CMD="zenity --title $PN --entry --hide-text"
+ GUI=true
fi
if ! [ -r /etc/grml_version ] ; then
- $DIALOG --title "$PN" --msgbox "Warning: this system does not look like a Grml (based) system
-and therefore might not work as intended." 7 70
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title "$PN" --warning --text "Warning: this system does not look like a Grml (based) system,\n
+ and therefore might not work as intended."
+ else
+ $DIALOG --title "$PN" --msgbox "Warning: this system does not look like a Grml (based) system
+ and therefore might not work as intended." 7 70
+ fi
fi
lock_desktop() {
}
set_passwd() {
- if [ "$DIALOG" = "gdialog" ] ; then
+ if [ "${GUI}" = true ] ; then
PASSWD1="$($PWD_CMD --text="$PWD_TEXT1")"
PASSWD2="$($PWD_CMD --text="$PWD_TEXT2")"
else
fi
if [ -z "$PASSWD1" ] ; then
- $DIALOG --title "$PN" --msgbox "Error retrieving password. Exiting." 0 0
+ if [ -n "${GUI}" ] ; then
+ $DIALOG --title "$PN" --error --text "Error retrieving password. Exiting."
+ else
+ $DIALOG --title "$PN" --msgbox "Error retrieving password. Exiting." 0 0
+ fi
exit 1
fi
+
if [ "$PASSWD1" = "$PASSWD2" ] ; then
echo "$USER:$PASSWD2" | sudo chpasswd
else
- $DIALOG --title "$PN" --msgbox "Error: passwords do not match. Exiting." 0 0
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title "$PN" --error --text "Error: passwords do not match.\nExiting."
+ else
+ $DIALOG --title "$PN" --msgbox "Error: passwords do not match. Exiting." 0 0
+ fi
exit 1
fi
}
askpwd() {
- if [ "$DIALOG" = "gdialog" ] ; then
- zenity --title="$PN" --question --cancel-label='Exit' --ok-label='Set password' --text="User $USER has no password set yet. Without a password you will not be able to log in again. Set password for user $USER?"
+ if [ "${GUI}" = true ] ; then
+ $DIALOG --no-wrap --title="$PN" --question --cancel-label='Exit' --ok-label='Set password' --text="User $USER has no password set yet.\nWithout a password you will not be able to log in again.\nSet password for user $USER?"
RC=$?
else
$DIALOG --title "$PN" --no-label Exit --yes-label Continue --yesno "User $USER has no password set yet. Without a password you will not be able to log in again. Set password for user $USER?" 0 0
if ! isgrmlcd ; then
lock_desktop
else
- is_passwd_set || askpwd
- [ "$?" = "0" ] && lock_desktop || exit 1
+ if is_passwd_set || askpwd ; then
+ lock_desktop
+ else
+ exit 1
+ fi
fi
## END OF FILE #################################################################
# License: This file is licensed under the GPL v2.
################################################################################
-PN=$(basename $0)
+PN="$(basename "$0")"
RESOLUTION=$(mktemp)
ERROR=$(mktemp)
bailout(){
- rm -f $RESOLUTION $ERROR
- exit $1
+ rm -f "$RESOLUTION" "$ERROR"
+ exit "$1"
}
trap bailout 1 2 3 15
STRING=""
# current mode
-CURRENT_NUM=$(xrandr | awk '/\*/ {print $1}' | tr -d '*')
-CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $2 $3 $4}')
+CURRENT_RESOLUTION=$(xrandr | awk '/\*/ {print $1"_"$2}')
# menu
-for i in $(xrandr | awk {'print $2$3$4'} | grep "^[0-9]") ; do
+for i in $(xrandr | awk '{print $1"_"$2}' | grep "^[0-9]") ; do
STRING="$STRING $COUNTER $i"
((COUNTER++))
done
# Menu Tool
-dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>$RESOLUTION
+# shellcheck disable=SC2086
+dialog --title "$PN" --menu "Change X resolution via xrandr (current resolution: $CURRENT_RESOLUTION):" 0 0 0 $STRING 2>"$RESOLUTION"
retval=$?
case $retval in
(1) echo "Cancel pressed." ; exit 1 ;;
(255) echo "ESC pressed." ; exit 1 ;;
esac
-CHOSE=$(cat $RESOLUTION)
+CHOSE=$(cat "$RESOLUTION")
-if [ "$CHOSE" = "$CURRENT_NUM" ] ; then
- dialog --title "$PN" --msgbox "Chosen resolution corresponds to current resolution. No changes needed." 0 0
-elif [ -n "$CHOSE" ] ; then
- xrandr -s $CHOSE 2>$ERROR && \
+if [ -n "$CHOSE" ] ; then
+# shellcheck disable=SC2015
+ xrandr -s "$CHOSE" 2>"$ERROR" && \
dialog --title "$PN" --msgbox "Running xrandr with resolution was succesful." 0 0 || \
- dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: `cat $ERROR`" 0 0
+ dialog --title "$PN" --msgbox "Error when running xrandr with resolution $CHOSE: $(cat "$ERROR")" 0 0
fi
}
main
done
-bailout
+bailout 0
# EOF #
find_all_images
for i in $ALL_IMAGES ; do
- if ! egrep "$i=" ./description >/dev/null ; then
+ if ! grep -E "$i=" ./description >/dev/null ; then
echo "$i=`description $i`" >> ./description
fi
}
if isutfenv ; then
- for ENV in `env | grep UTF` ; do
- eval export "$(echo $ENV | sed 's/UTF-8/iso885915/')"
+ for ENV in $(env | grep UTF) ; do
+ eval export "$(echo "$ENV" | sed 's/UTF-8/iso885915/')"
done
- ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator $*
-else
- ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator $*
fi
+ZSH_NO_DEFAULT_LOCALE=1 x-terminal-emulator "$@"
## END OF FILE #################################################################
port = 8901
logfile = os.path.expanduser("~/.event.log")
osdparams = "-p bottom --color=red --delay=4 --age=4 " \
- "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \
+ "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \ # noqa: W605,E501
"--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
actions = (
(".*", [log], True),
"""
+import getopt
+import logging
import os
-import sys
import re
-import string
import socket
-import logging
-import getopt
+import string
import subprocess
+import sys
-default_hostname = 'localhost'
+default_hostname = "localhost"
default_port = 1234
-default_osd_params = osdparams = "-p bottom --color=red --delay=4 --age=4 " \
- "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " \
- "--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
+default_osd_params = osdparams = (
+ "-p bottom --color=red --delay=4 --age=4 "
+ "--font=\-\*\-helvetica\-medium\-r\-\*\-\*\-34\-\*\-\*\-\*\-\*\-\*\-\*\-15 " # noqa: W605,E501
+ "--offset=100 --shadow=0 --lines=5 --align=right --indent=100"
+)
default_logfile = None
def play(sound_file):
def play_wrapper(msg):
- with open(os.devnull, 'w') as devnull:
- subprocess.Popen(['/usr/bin/aplay', sound_file], stderr=devnull)
+ with open(os.devnull, "w") as devnull:
+ subprocess.Popen(["/usr/bin/aplay", sound_file], stderr=devnull)
+
return play_wrapper
+
def execute(command):
def command_wrapper(msg):
- subprocess.call(command % dict(msg = msg))
+ subprocess.call(command % dict(msg=msg))
+
return command_wrapper
+
def osd(msg):
osdcmd = "/usr/bin/osd_cat"
- osdpipe = os.popen("%s %s" % (osdcmd, osdparams), 'w')
+ osdpipe = os.popen("%s %s" % (osdcmd, osdparams), "w")
osdpipe.write(msg)
osdpipe.close()
+
def libnotify(msg):
try:
import dbus
except ImportError:
- sys.stderr.write('Please install python-dbus\n')
+ sys.stderr.write("Please install python-dbus\n")
raise SystemExit(1)
bus = dbus.SessionBus()
- notifyService = bus.get_object("org.freedesktop.Notifications", '/org/freedesktop/Notifications')
- interface = dbus.Interface(notifyService, 'org.freedesktop.Notifications')
+ notifyService = bus.get_object(
+ "org.freedesktop.Notifications", "/org/freedesktop/Notifications"
+ )
+ interface = dbus.Interface(notifyService, "org.freedesktop.Notifications")
- message, title = (':' + msg).split(':')[::-1][0:2]
+ message, title = (":" + msg).split(":")[::-1][0:2]
if not title:
title, message = message, title
- interface.Notify('notify-server', 0, 'notification-message-im', title, message, [], {'x-canonical-append':'allowed'}, -1)
+ interface.Notify(
+ "notify-server",
+ 0,
+ "notification-message-im",
+ title,
+ message,
+ [],
+ {"x-canonical-append": "allowed"},
+ -1,
+ )
+
def log(msg):
if logger:
logger.info(msg)
+
def syntax():
- print "osd_server.py [options]"
- print " options:"
- print " -h --help print this message"
- print " -H --host host of the osd server (def: " + default_hostname + ")"
- print " -P --port port of the osd server (def: " + str(default_port) + ")"
- print " -l --log log file ('-' logs to stdout)"
-
-
-env = { 'play' : play,
- 'execute' : execute,
- 'osd' : osd,
- 'libnotify' : libnotify,
- 'log' : log,
- 'host' : default_hostname,
- 'port' : default_port,
- 'logfile' : default_logfile,
- }
+ print("osd_server.py [options]")
+ print(" options:")
+ print(" -h --help print this message")
+ print(" -H --host host of the osd server (def: " + default_hostname + ")")
+ print(
+ " -P --port port of the osd server (def: " + str(default_port) + ")"
+ )
+ print(" -l --log log file ('-' logs to stdout)")
+
+
+env = {
+ "play": play,
+ "execute": execute,
+ "osd": osd,
+ "libnotify": libnotify,
+ "log": log,
+ "host": default_hostname,
+ "port": default_port,
+ "logfile": default_logfile,
+}
default_actions = (
(".*", [log], True),
default_bind = (default_hostname, default_port)
try:
- execfile(os.path.expanduser('~/.notifyd.conf'), {}, env)
+ exec(
+ compile(
+ open(os.path.expanduser("~/.notifyd.conf"), "rb").read(),
+ os.path.expanduser("~/.notifyd.conf"),
+ "exec",
+ ),
+ {},
+ env,
+ )
except IOError:
pass
try:
- opts, args = getopt.getopt(sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="])
+ opts, args = getopt.getopt(
+ sys.argv[1:], "hH:P:l:", ["help", "host=", "port=", "log="]
+ )
except getopt.GetoptError:
syntax()
sys.exit(2)
syntax()
sys.exit(3)
elif opt in ("-H", "--host"):
- env['host'] = arg
+ env["host"] = arg
elif opt in ("-P", "--port"):
- env['port'] = int(arg)
+ env["port"] = int(arg)
elif opt in ("-l", "--log"):
- env['logfile'] = arg
+ env["logfile"] = arg
-actions = env.get('actions', default_actions)
-logfile_name = env.get('logfile')
-logfile_format = env.get('logformat', '%(asctime)s %(message)s')
-bind_address = (env['host'], env['port'])
-osd_params = env.get('osdparams', default_osd_params)
+actions = env.get("actions", default_actions)
+logfile_name = env.get("logfile")
+logfile_format = env.get("logformat", "%(asctime)s %(message)s")
+bind_address = (env["host"], env["port"])
+osd_params = env.get("osdparams", default_osd_params)
if logfile_name:
- logger = logging.getLogger('notify_server')
+ logger = logging.getLogger("notify_server")
lformatter = logging.Formatter(logfile_format)
- if logfile_name not in ('', '-'):
+ if logfile_name not in ("", "-"):
lfh = logging.FileHandler(logfile_name)
lfh.setFormatter(lformatter)
logger.addHandler(lfh)
else:
logger = None
-l = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
-l.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
-l.bind(bind_address)
-l.listen(5)
+listen = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+listen.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
+listen.bind(bind_address)
+listen.listen(5)
+
def filter_char(c):
- return c in string.printable + "Ă¤Ă¶Ă¼ĂŸĂ„Ă–Ăœ" and c or '_'
+ return c in string.printable + "Ă¤Ă¶Ă¼ĂŸĂ„Ă–Ăœ" and c or "_"
+
while 1:
try:
- (con, addr) = l.accept()
- except:
+ (con, addr) = listen.accept()
+ except OSError:
continue
data = con.recv(50).strip()
con.close()
- log = ''.join(filter_char(c) for c in data)
+ log = "".join(filter_char(c) for c in data)
for pattern, handlers, cont in actions:
if re.match(pattern, log):
# Bug-Reports: see http://grml.org/bugs/
# License: This file is licensed under the GPL v2.
################################################################################
-num=$(wc -l $0)
-num=${num%% $0}
-num=$(( $num - 16 ))
-randline=$(($(date +%Y%M%S) * $$ % $num))
-hostname=$(tail -n $randline "$0" | head -1 | grep -v "'" | grep -v '^#' | grep -v '^$')
+hostname_start=$(grep -n "^# EOF" "$0")
+hostname_start=${hostname_start%%:#*}
+hostname_start=$(( hostname_start + 3 ))
+hostname=$(tail -n +$hostname_start "$0" | grep -v "'" | grep -v '^#' | grep -v '^$' | sort -R | tail -1)
[ -n "$hostname" ] && echo "$hostname" || echo "grml"
-# EOF - line 15; now the hostnames:
+# EOF - now the hostnames:
+# shellcheck disable=SC2034
hostnames='
23
42
# License: This file is licensed under the GPL v2.
################################################################################
-if ! [ $(which speaker-test) ] ; then
+if ! [ "$(command -v speaker-test)" ] ; then
echo "Sorry, speaker-test (from alsa-utils) not available.">&2
exit 1
fi
# License: This file is licensed under the GPL v2.
################################################################################
-PN="$(basename $0)"
+PN="$(basename "$0")"
[ -n "$MODPROBEFILE" ] || MODPROBEFILE=/etc/modprobe.d/grml.conf
+# shellcheck disable=SC1091
[ -r /etc/grml/lsb-functions ] && . /etc/grml/lsb-functions
if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
fi
if [ "$(id -ru)" != "0" ] ; then
- echo Error: become root before starting $0 >& 2
+ echo "Error: become root before starting $0" >& 2
exit 100
fi
set -e
+# shellcheck disable=SC1091
. /etc/grml/script-functions
+# shellcheck disable=SC1091
. /etc/grml/lsb-functions
check4root
# TODO / integrate?
cronsetup() {
- test -f ~/.keychain/`uname -n`-sh && . ~/.keychain/`uname -n`-sh
+# shellcheck disable=SC1090
+ test -f "${HOME}/.keychain/$(uname -n)-sh" && . "${HOME}/.keychain/$(uname -n)-sh"
}
get_backup_dir() {
if ! [ -d "$BACKUP_DIR" ] ; then
dialog --stdout --title "${PN}" --yesno "The directory $BACKUP_DIR does not yet exist. Do you want me to create it for you? " 0 0
+ RC=$?
- if [ $? -eq 0 ]; then
+ if [ ${RC} -eq 0 ]; then
echo "mkdir $BACKUP_DIR"
echo "chmod 700 $BACKUP_DIR"
else
}
sshkey_setup() {
- CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@$(hostname))"
+ CLIENTNAME="$(dialog --stdout --inputbox 'Please choose user login and hostname for the client you want to backup. Syntax: user@host' 0 0 root@"$(hostname)")"
dialog --stdout --title "${PN}" --yesno "Do you want me to create ssh setup for client ${CLIENTNAME} using ssh-keygen and ssh-copy-id?" 0 0
+ RC=$?
- if [ $? -eq 0 ]; then
+ if [ ${RC} -eq 0 ]; then
[ -d "$HOME/.ssh" ] || mkdir "$HOME/.ssh"
einfo "Creating $HOME/.ssh/id_rsa_dirvish_${CLIENT} using ssh-keygen:"
ssh-keygen -t rsa -f "$HOME/.ssh/id_rsa_dirvish_${CLIENT}" ; eend $?
einfo "Running ssh-copy-id to copy ssh key to $CLIENTNAME:"
- ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" $CLIENTNAME ; eend $?
+ ssh-copy-id -i "$HOME/.ssh/id_rsa_dirvish_${CLIENT}.pub" "$CLIENTNAME" ; eend $?
fi
}
client_setup() {
dialog --stdout --title "${PN}" --yesno "Do you want to backup $CLIENT via network? Answering with no will use localhost [$(hostname)] as client." 0 0
+ RC=$?
- if [ $? -eq 0 ]; then
+ if [ ${RC} -eq 0 ]; then
sshkey_setup
else
CLIENTNAME=$(hostname) # use localhost only
einfo "Running $PN was successful. Enjoy using dirvish!" ; eend 0
echo
einfo "Please adjust ${BACKUP_DIR}/${CLIENT}/dirvish/default.conf according to your needs.
-$MASTERINFO
+$MASTERINFO
Then run the following command to create an initial backup:
dirvish --summary long --vault $CLIENT --init
# License: This file is licensed under the GPL v2.
################################################################################
-PROG_NAME_=$(basename $0)
+PROG_NAME_=$(basename "$0")
DEST_=""
MOUNTED_="" # all mounted destinations
function die
{
- echo "Error: $@" >&2
+ echo "Error: $*" >&2
exit 1
}
local dest_="$2"
local options_="$3"
- local all_options_=""
+ local all_options_=()
if [[ $options_ == "--bind" ]]; then
- all_options_="--bind $type_"
+ all_options_+=(--bind "$type_")
else
- all_options_="-t $type_ none"
+ all_options_+=(-t "$type_" none)
fi
- mount $all_options_ "${DEST_}/$dest_" && storeMounts "$dest_"
+ mount "${all_options_[@]}" "${DEST_}/$dest_" && storeMounts "$dest_"
}
function umount_all
{
- local reverse=$(echo $MOUNTED_ | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
+ local reverse
+ reverse=$(echo "$MOUNTED_" | awk '{ for (i=NF; i>1; i--) printf("%s ",$i); print $1; }')
for i in $reverse; do
umount "${DEST_}/$i"
done
?) printUsage; exit 64 ;;
esac
done
-shift $(($OPTIND - 1))
+shift $((OPTIND - 1))
if (( $# < 1 )); then
printUsage
die "Wrong number of arguments."
fi
-if ! which awk >/dev/null 2>&1 ; then
+if ! command -v awk >/dev/null 2>&1 ; then
die "No awk binary found, required for execution."
fi
mountit "sysfs" "sys"
mountit "/dev" "dev" "--bind"
mountit "devpts" "dev/pts"
+ if [ -d /sys/firmware/efi/efivars ] ; then
+ mountit "efivarfs" "sys/firmware/efi/efivars"
+ fi
if [ -d "$DEST_"/run/udev ] && [ -d /run/udev ] ; then
mountit "/run/udev" "/run/udev" "--bind"
fi
fi
umount_all
-if [ ! -z "$WROTE_DEBIAN_CHROOT" ]; then
+if [ -n "$WROTE_DEBIAN_CHROOT" ]; then
rm "$DEST_"/etc/debian_chroot
fi
PATH=${PATH:-'/bin/:/sbin/:/usr/bin:/usr/sbin'}
# set up some variables
-DIALOG=`which dialog`
-PN=$(basename $0)
+DIALOG=$(command -v dialog)
+PN=$(basename "$0")
if [ "$(id -ru)" != "0" ] ; then
$DIALOG --msgbox "Error: $0 requires root permissions. Exiting." 0 0
# License: This file is licensed under the GPL v2.
################################################################################
+# shellcheck disable=SC1091
. /etc/grml/script-functions
check4root || exit 1
if [ -z "$NONINTERACTIVE" ] ; then
NEW_HOSTNAME="$(dialog --stdout --title "${PN}" --extra-button --extra-label "Propose hostname" \
--inputbox "Set hostname (/etc/hostname, /etc/hosts and /etc/postfix/main.cf will be adjusted)\
-\n\nTip: press 'Propose hostname' for another proposal" 14 70 $NEW_HOSTNAME)"
+\\n\\nTip: press 'Propose hostname' for another proposal" 14 70 "$NEW_HOSTNAME")"
retval=$?
else
retval=0
0)
echo "$NEW_HOSTNAME" > /etc/hostname
echo "$NEW_HOSTNAME" > /etc/mailname
+ # shellcheck disable=SC1117
sed -ir "s/^\(127.0.0.1\s*\).*localhost.*/\1$NEW_HOSTNAME localhost/" /etc/hosts
+ # shellcheck disable=SC1117
sed -ir "s/^\(::1\s*\).*ip6-localhost.*/\1ip6-localhost ip6-loopback $NEW_HOSTNAME/" /etc/hosts
POSTFIX=''
fi
if [ -n "$DISPLAY" ] ; then
- if sudo -u $RUNASUSER xauth add $(xauth -n list | grep "${OLDHOSTNAME}/unix:0" | sed "s|${OLDHOSTNAME}/unix:0|${NEW_HOSTNAME}/unix:0|") ; then
+ if sudo -u $RUNASUSER xauth add "$(xauth -n list | grep "${OLDHOSTNAME}/unix:0" | sed "s|${OLDHOSTNAME}/unix:0|${NEW_HOSTNAME}/unix:0|")" ; then
sudo -u $RUNASUSER xauth remove "${OLDHOSTNAME}/unix:0"
fi
fi
# License: This file is licensed under the GPL v2.
################################################################################
+# shellcheck disable=SC1091
. /etc/grml/script-functions
+# shellcheck disable=SC1091
. /etc/grml/lsb-functions
check4progs iptstate || exit 1
ewarn "Module ip_conntrack is not present. Can not start iptstate therefore."
eindent
einfon "Do you want to load it and invoke iptstate afterwards? [YES|no] "
- read a
- if [ "$a" = YES -o "$a" = yes -o "$a" = '' -o "$a" = y -o "$a" = Y ] ; then
+ read -r a
+ a=$(echo "$a" | tr '[:upper:]' '[:lower:]')
+ if [ "$a" = "yes" ] || [ "$a" = "y" ] || [ "$a" = "" ] ; then
modprobe ip_conntrack ; RC=$?
eend $RC
[ "$RC" = 0 ] && exec iptstate
# License: This file is licensed under the GPL v2.
################################################################################
-PN="$(basename $0)"
+PN="$(basename "$0")"
DIALOG=dialog
CMDLINE=/proc/cmdline
+# shellcheck disable=SC1091
. /etc/grml/script-functions
check4root || exit 1
setvalue(){
[ -n "$2" ] || return 1
# already present in conffile?
- if grep -q ${1} $CONFFILE ; then
- sed -i "s#^${1}.*#${1}=${2}#" $CONFFILE
+ if grep -q "${1}" "$CONFFILE" ; then
+ sed -i "s#^${1}.*#${1}=${2}#" "$CONFFILE"
else
- echo "$1=${2}" >> $CONFFILE
+ echo "$1=${2}" >> "$CONFFILE"
fi
}
return 0
}
+# shellcheck disable=SC1091
[ -r /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard
[ -n "$KEYTABLE" ] && DEFAULT_KEYBOARD="$KEYTABLE"
fi
fi
+# shellcheck disable=SC1010
+{
LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_KEYBOARD --radiolist \
"Which keyboard layout do you want to use?
tw "chinese (traditional)" off \
uk british off \
)
+}
retval=$?
case $retval in
esac
# read in the file where all the $LANGUAGE stuff is defined
- . /etc/grml/language-functions
+# shellcheck disable=SC1091
+. /etc/grml/language-functions
cat > /etc/sysconfig/keyboard <<EOF
# File generated by $PN on $(date)
# License: This file is licensed under the GPL v2.
################################################################################
-PN="$(basename $0)"
+PN="$(basename "$0")"
DIALOG=dialog
-CMDLINE=/proc/cmdline
LANGFUNC=/etc/grml/language-functions
# notice: Debian's locales.postinst has been modified to write
# so modifying it was a policy violation.
CONFFILE=/etc/default/locale
+# shellcheck disable=SC1091
+{
. /etc/grml/script-functions
. /etc/grml/lsb-functions
+}
check4root || exit 100
sed -i "s#^${1}.*#${1}${2}#" $CONFFILE
# is the new Debian style /etc/default/locale present?
elif grep -q "^# ${1}$" "$CONFFILE" ; then
+ # shellcheck disable=SC1117
sed -i "s#^\# ${1}#${1}${2}#" $CONFFILE
else
echo "$1${2}" >> $CONFFILE
fi
fi
+# shellcheck disable=SC1091
+{
[ -r /etc/environment ] && . /etc/environment
[ -r /etc/default/locale ] && . /etc/default/locale
+}
[ -n "$LANGUAGE" ] && DEFAULT_LANGUAGE="$LANGUAGE"
if [ -z "$DEFAULT_LANGUAGE" ] ; then
fi
if [ -z "$NONINTERACTIVE" ] ; then
+# shellcheck disable=SC1010
+{
LANGUAGE=$(LANG=C $DIALOG --stdout --title "$PN" --default-item $DEFAULT_LANGUAGE --radiolist \
"Which language do you want to use?
us 'american (unicode version)' off \
us-iso 'american (iso version)' off \
)
+}
retval=$?
case $retval in
# fallback to C if using an ISO system (which is latin1 for LC_CTYPE);
# this should prevent users from broken ctype settings if the set
# locale isn't available on a remote system
-if echo $LANGUAGE | grep -q -- '-iso' ; then
+if echo "$LANGUAGE" | grep -q -- '-iso' ; then
LC_CTYPE=C
fi
# read in the file where all the $LANGUAGE stuff is defined
- . $LANGFUNC
+# shellcheck disable=SC1090
+. $LANGFUNC
# make sure the file exists
if ! [ -r $CONFFILE ] ; then
EOF
fi
-setvalue 'LANG=' $LANG
+setvalue 'LANG=' "$LANG"
retval=$?
case $retval in
# License: This file is licensed under the GPL v2.
################################################################################
-PN="$(basename $0)"
+PN="$(basename "$0")"
TMP=$(mktemp)
DIALOG=dialog
CONFFILE='/etc/runlevel.conf'
+# shellcheck disable=SC1091
+{
. /etc/grml/script-functions
. /etc/grml/lsb-functions
+}
check4root || exit 100
is_value_set(){
[ -n "$1" ] || return 2
[ -r "$TMP" ] || return 3
- grep -q "$1" $TMP && return 0 || return 1
+ grep -q "$1" "$TMP" && return 0 || return 1
}
INFO="Which services would you like to have enabled on your system?
[ -r /etc/init.d/lvm2 ] && LVM='lvm!logical volume management!on'
[ -r /etc/init.d/mdadm ] && SRAID='mdadm!software-raid via mdadm!on'
[ -r /etc/init.d/dmraid ] && MRAID='dmraid!software-raid via dmraid!off'
-[ -r /etc/init.d/dbus -o -r /etc/init.d/dbus-1 ] && DBUS='dbus!hal/dbus (important for KDE e.g.)!off'
+[ -r /etc/init.d/dbus ] || [ -r /etc/init.d/dbus-1 ] && DBUS='dbus!hal/dbus (important for KDE e.g.)!off'
[ -r /etc/init.d/hal ] && HAL='hal!Hardware Abstraction Layer daemon (important for KDE e.g.)!off'
[ -r /etc/init.d/nfs-common ] && NFS='nfs!Network File System (client setup)!off'
# the interface itself
oifs="$IFS"
IFS='!'
-$DIALOG --title "$PN" --checklist "$INFO" 30 65 8 $LVM $SRAID $MRAID $DBUS $HAL $NFS 2>$TMP
+$DIALOG --title "$PN" --checklist "$INFO" 30 65 8 "$LVM" "$SRAID" "$MRAID" "$DBUS" "$HAL" "$NFS" 2>"$TMP"
retval="$?"
case $retval in
;;
esac
-rm -f $TMP
+rm -f "$TMP"
IFS="$oifs"
## END OF FILE #################################################################
-#!/bin/sh
+#!/bin/bash
# Filename: grml2ram
# Purpose: copy compressed GRML image to RAM
# Authors: (c) Michael Schierl <schierlm-public@gmx.de>, (c) Michael Prokop <mika@grml.org>
set -e
+# shellcheck disable=SC1091
. /etc/grml/lsb-functions
+# shellcheck disable=SC1091
. /etc/grml/script-functions
check4root || exit 1
MEDIA_PATH="$(getbootparam live-media-path)"
MEDIA_PATH="${MEDIA_PATH:-.}"
-IMAGE=$(find ${LIVECD_PATH}/${MEDIA_PATH}/ -name *.squashfs 2>/dev/null | head -1)
+IMAGE=$(find "${LIVECD_PATH}/${MEDIA_PATH}/" -name "*.squashfs" 2>/dev/null | head -1)
if ! [ -r "$IMAGE" ] ; then
if [ -r /cdrom/GRML/GRML ] ; then
IMAGE='/cdrom/GRML/GRML'
GRMLSIZE="$(du $IMAGE | awk '{print $1}')"
RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo)
+LOOPDEV=$(/sbin/losetup -j "${IMAGE}" -n -O NAME)
case "$*" in -f|--force)
ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0
;;
*)
- if test $RAM -lt $GRMLSIZE ; then
+ if test "$RAM" -lt "$GRMLSIZE" ; then
eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1
exit 1
fi
einfo "Copying $IMAGE to RAM, this might take a while."
rsync -a --progress $IMAGE /tmp/GRML
LANGUAGE=C LANG=C LC_ALL=C perl << EOF
-open LOOP, '</dev/loop0' or die $!;
+open LOOP, '<${LOOPDEV}' or die $!;
open DEST, '</tmp/GRML' or die $!;
ioctl(LOOP, 0x4C06, fileno(DEST)) or die $!;
close LOOP;
[ -n "$GRMLDEV" ] || GRMLDEV='/dev/cdrom'
einfo "Unmounting cdrom"
-[ -d $LIVECD_PATH ] && umount $LIVECD_PATH || umount /cdrom
+if [ -d $LIVECD_PATH ] ;
+then
+ umount $LIVECD_PATH
+else
+ umount /cdrom
+fi
eend $?
einfo "Now you can eject your grml-cd (e.g. run 'eject $GRMLDEV')." ; eend 0
################################################################################
touch /etc/noeject
-exec $*
+exec "$@"
## END OF FILE #################################################################
################################################################################
touch /etc/noprompt
-exec $*
+exec "$@"
## END OF FILE #################################################################
# License: This file is licensed under the GPL v2.
################################################################################
+export SHELL=/bin/zsh
# try to mitigate raceconditions from screen
SCREENDIR_="/var/run/screen"
mkdir -m 700 "${SCREENDIR_}/S-$USER" >/dev/null 2>&1
# now run screen with config
- if [ `id -u` = 0 ] ; then
- exec screen -U -c /etc/grml/screenrc
+ if [ "$(id -u)" = 0 ] ; then
+ exec screen -U -c /etc/grml/screenrc -s "-$SHELL"
elif [ -r "$HOME/.screenrc" ] ; then
- exec screen -U -c "$HOME/.screenrc"
+ exec screen -U -c "$HOME/.screenrc" -s "-$SHELL"
else
- exec screen -U -c /etc/grml/screenrc_generic
+ exec screen -U -c /etc/grml/screenrc_generic -s "-$SHELL"
fi
## END OF FILE #################################################################
# License: This file is licensed under the GPL v2.
################################################################################
+# shellcheck disable=SC1091
. /etc/grml/sh-lib
+export SHELL=/bin/zsh
+
[ -r /etc/grml_version ] && GRMLVERSION=$(cat /etc/grml_version) || GRMLVERSION='(no version information available)'
PATH=$HOME/bin:/bin:/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/usr/games:/home/grml/bin
CMDLINE=$(cat /proc/cmdline)
# allow customized startup via bootoption startup:
*startup=*)
script="$(getBootParam startup)"
- if [ -x $(which $script) ] ; then
+ if [ -x "$(command -v "$script")" ] ; then
$script
fi
;;
;;
*) # by default run grml-quickconfig, but only if running as root
if [ "$(id -u)" = "0" ] ; then
- which grml-quickconfig &>/dev/null && grml-quickconfig
+ command -v grml-quickconfig &>/dev/null && grml-quickconfig
fi
esac
"
fi
-exec /bin/zsh -l
+exec "$SHELL" -l
## END OF FILE #################################################################