Skip to content
Snippets Groups Projects
Commit 6face76e authored by James Vasile's avatar James Vasile
Browse files

Add admin script to silicon

parent 66658eaf
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# Do - The Simplest Build Tool on Earth.
# Documentation and examples see https://github.com/8gears/do
set -eu
VERSION="0.0.1"
SCRIPTNAME=`basename "$0"`
BASEDIR=$(realpath $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ))
if [ "$(id -u)" -ne 0 ]; then
echo 'This script must be run by root' >&2
exit 1
fi
_apt-get-install () {
DPKG=`dpkg -l`
packages=("$@")
for file in "${packages[@]}"; do
if ! echo "$DPKG" | grep -qF "$file"; then
apt-get install -y $@
break
fi
done
}
lid-off() {
echo Turning off lid-triggered sleep
mkdir -p /etc/systemd/logind.conf.d
pushd /etc/systemd/logind.conf.d
echo -e '[Login]\nHandleLidSwitch=ignore\nHandleLidSwitchExternalPower=ignore\nHandleLidSwitchDocked=ignore\nLidSwitchIgnoreInhibited=yes' > lid.conf
popd
systemctl reload systemd-logind
}
lid-on() {
echo Turning on lid-triggered sleep
rm /etc/systemd/logind.conf.d/lid.conf
systemctl reload systemd-logind
}
"$@" # <- execute the task
[ "$#" -gt 0 ] || printf "Usage:\n\t./${SCRIPTNAME} %s\n" "($(compgen -A function | grep '^[^_]' | paste -sd '|' -))"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment