From 81836945a63f726033fb6550755e2c9dbf1a1f83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 3 Apr 2017 20:42:16 +0200 Subject: Add system_install --- install | 8 ----- system/etc/acpi/handler.sh | 79 ++++++++++++++++++++++++++++++++++++++++++++ system/etc/pm/sleep.d/10lock | 13 ++++++++ system_install | 37 +++++++++++++++++++++ utils/inst | 12 +++++++ 5 files changed, 141 insertions(+), 8 deletions(-) create mode 100755 system/etc/acpi/handler.sh create mode 100755 system/etc/pm/sleep.d/10lock create mode 100755 system_install diff --git a/install b/install index 786a1ba..13a2469 100755 --- a/install +++ b/install @@ -10,14 +10,6 @@ git submodule update --init || (echo "Submodule update failed!"; exit 5) ################################################################################# source private/install # private files, sorry but some privacy is required. -if [ -e /etc/arch-release ]; then - . ./utils/arch - read -p "Check Archlinux packages? (Y/n) " - if [[ $REPLY =~ ^[Yy]?$ ]]; then - archlinux_inst - fi -fi - read -p "Install Bashrc? (Y/n) " if [[ $REPLY =~ ^[Yy]?$ ]]; then inst bashrc ~/.bashrc diff --git a/system/etc/acpi/handler.sh b/system/etc/acpi/handler.sh new file mode 100755 index 0000000..1cc28ff --- /dev/null +++ b/system/etc/acpi/handler.sh @@ -0,0 +1,79 @@ +#!/bin/bash +# Default acpi script that takes an entry for all actions + +case "$1" in + button/power) + case "$2" in + PBTN|PWRF) + logger 'PowerButton pressed' + ;; + *) + logger "ACPI action undefined: $2" + ;; + esac + ;; + button/sleep) + case "$2" in + SLPB|SBTN) + pm-suspend + logger 'SuspendButton pressed' + ;; + *) + logger "ACPI action undefined: $2" + ;; + esac + ;; + ac_adapter) + case "$2" in + AC|ACAD|ADP0) + case "$4" in + 00000000) + logger 'AC unpluged' + echo 1000 > /sys/class/backlight/intel_backlight/brightness + ;; + 00000001) + logger 'AC pluged' + echo 5273 > /sys/class/backlight/intel_backlight/brightness + ;; + esac + ;; + *) + logger "ACPI action undefined: $2" + ;; + esac + ;; + battery) + case "$2" in + BAT0) + case "$4" in + 00000000) + logger 'Battery online' + ;; + 00000001) + logger 'Battery offline' + ;; + esac + ;; + CPU0) + ;; + *) logger "ACPI action undefined: $2" ;; + esac + ;; + button/lid) + case "$3" in + close) + logger 'LID closed' + pm-suspend + ;; + open) + logger 'LID opened' + ;; + *) + logger "ACPI action undefined: $3" + ;; + esac + ;; + *) + logger "ACPI group/action undefined: $1 / $2" + ;; +esac diff --git a/system/etc/pm/sleep.d/10lock b/system/etc/pm/sleep.d/10lock new file mode 100755 index 0000000..da7c018 --- /dev/null +++ b/system/etc/pm/sleep.d/10lock @@ -0,0 +1,13 @@ +#!/bin/sh +# +# 10sleep: lock i3 season before suspend + +case "$1" in + hibernate|suspend) + for socket in `find /run/user/*/i3 -name ipc-socket*`; do + i3-msg -s $socket "exec i3lock -d -c 000000" + done + ;; + *) exit $NA + ;; +esac diff --git a/system_install b/system_install new file mode 100755 index 0000000..1caf757 --- /dev/null +++ b/system_install @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ "$UID" -ne 0 ]; then + echo "Please run this as root!" >&2 + exit 6 +fi + +cd `dirname $0` + +git submodule update --init || (echo "Submodule update failed!"; exit 5) + +# Source inst and diff function +. ./utils/inst + +################################################################################# + +if [ -e /etc/arch-release ]; then + . ./utils/arch + read -p "Check Archlinux packages? (Y/n) " + if [[ $REPLY =~ ^[Yy]?$ ]]; then + archlinux_inst + fi +fi + +read -p "Laptop ACPI and pm? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + inst system/etc/acpi/handler.sh /etc/acpi/handler.sh + inst system/etc/pm/sleep.d/10lock /etc/pm/sleep.d/10lock +fi + +read -p "Wpa supplicant? (Y/n) " +if [[ $REPLY =~ ^[Yy]?$ ]]; then + # TODO +fi + +# As final step just ensure that correct user is owning system files +chown -R $(stat -c "%U:%G" "$0") system diff --git a/utils/inst b/utils/inst index cb1f658..b9da163 100644 --- a/utils/inst +++ b/utils/inst @@ -97,3 +97,15 @@ inst() { fi doinst $1 $2 } + +# gpg encrypted install +ginst() { + if [ -z "$PASS" ]; then + PASS="$(gpg --batch --decrypt pass.gpg)" + fi + # TODO probably we should be sure that file will be always removed + local TMP="$(mktemp myconfigs.XXXXXXXXXX)" + gpg --batch --passphase "$PASS" --output "$TMP" --decrypt "$1" + inst "$TMP" "$2" + gpg --batch --passphase "$PASS" --output "$1" --encrypt "$TMP" +} -- cgit v1.2.3