From 07ace11a337c3b5874fa53f2682cad12e58762a6 Mon Sep 17 00:00:00 2001 From: Dustin Kirkland Date: Thu, 4 Feb 2010 18:57:17 -0800 Subject: [PATCH] * debian/config, debian/postinst, debian/prerm, debian/rules, debian/templates, usr/bin/byobu, usr/bin/byobu-launcher, usr/bin/byobu-launcher-install, usr/bin/byobu-launcher-uninstall: - support a preseedable debconf question that allows an administrator to launch byobu by default on all logins on a system (default = false), allow for per-user overriding --- debian/changelog | 6 ++++++ debian/config | 9 +++++++++ debian/postinst | 10 ++++++++++ debian/prerm | 1 + debian/rules | 1 - debian/templates | 11 +++++++++++ usr/bin/byobu | 5 +++++ usr/bin/byobu-launcher | 24 ++++++++++++++++++++++++ usr/bin/byobu-launcher-install | 1 + usr/bin/byobu-launcher-uninstall | 3 ++- 10 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 debian/config create mode 100644 debian/templates create mode 100755 usr/bin/byobu-launcher diff --git a/debian/changelog b/debian/changelog index 22ec7231..ebb8a049 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,12 @@ byobu (2.52) unreleased; urgency=low * debian/rules, usr/bin/byobu, usr/bin/byobu-launcher: deprecate the launcher script as a separate script; do this in /usr/bin/byobu + * debian/config, debian/postinst, debian/prerm, debian/rules, + debian/templates, usr/bin/byobu, usr/bin/byobu-launcher, + usr/bin/byobu-launcher-install, usr/bin/byobu-launcher-uninstall: + - support a preseedable debconf question that allows + an administrator to launch byobu by default on all logins on a + system (default = false), allow for per-user overriding -- Dustin Kirkland Wed, 03 Feb 2010 10:56:23 -0800 diff --git a/debian/config b/debian/config new file mode 100644 index 00000000..70b4564f --- /dev/null +++ b/debian/config @@ -0,0 +1,9 @@ +#! /bin/sh -e + +. /usr/share/debconf/confmodule +db_version 2.0 + +db_input medium byobu/launch-by-default || true +db_go + +exit 0 diff --git a/debian/postinst b/debian/postinst index 3b580776..6084603a 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,7 +1,17 @@ #!/bin/sh -e +. /usr/share/debconf/confmodule +db_version 2.0 + PKG="byobu" +db_get byobu/launch-by-default +if [ "$RET" = true ]; then + ln -sf /usr/bin/$PKG-launcher /etc/profile.d/$PKG.sh +else + rm -f /etc/profile.d/$PKG.sh +fi + # The target of the diversion somehow disappeared which will cause # the divert removal to fail; we don't want that to happen [ -e "/usr/bin/screen.real" ] && [ ! -e "/usr/bin/screen" ] && cp -a /usr/bin/screen.real /usr/bin/screen diff --git a/debian/prerm b/debian/prerm index fd906d78..baacc027 100644 --- a/debian/prerm +++ b/debian/prerm @@ -6,6 +6,7 @@ PKG="byobu" for i in /usr/bin/screen-profiles-status /usr/bin/screen-launcher; do [ -h "$i" ] && rm -f "$i" done +rm -f /etc/profile.d/$PKG.sh true diff --git a/debian/rules b/debian/rules index db871531..f82df523 100755 --- a/debian/rules +++ b/debian/rules @@ -54,7 +54,6 @@ install: build install-po #dh_link usr/bin/byobu-status usr/bin/screen-profiles-status #dh_link usr/bin/byobu-launcher usr/bin/screen-launcher dh_link usr/share/byobu/keybindings/f-keys usr/share/byobu/keybindings/common - dh_link usr/bin/byobu usr/bin/byobu-launcher for i in black dark dark_blue dark_cyan dark_green dark_purple dark_red dark_yellow light light_blue light_cyan light_green light_purple light_red light_yellow; do dh_link usr/share/byobu/profiles/common usr/share/byobu/profiles/$${i}; done dh_install -X.bzr diff --git a/debian/templates b/debian/templates new file mode 100644 index 00000000..347ae148 --- /dev/null +++ b/debian/templates @@ -0,0 +1,11 @@ +Template: byobu/launch-by-default +Type: boolean +Default: false +Description: Do you want to launch Byobu at shell login for all users? + Byobu can launch automatically at login (e.g. console, ssh), providing + an attachable/detachable window manager on the command line. + . + If you select this option, Byobu will install a symlink in /etc/profile.d. + This setting is system-wide, for all users logging into the system. + . + Individual users can disable this by touching ~/.byobu/disable-autolaunch. diff --git a/usr/bin/byobu b/usr/bin/byobu index b0dfecdf..dc762a9f 100755 --- a/usr/bin/byobu +++ b/usr/bin/byobu @@ -27,6 +27,11 @@ if [ "$#" = "1" ] && [ "$1" = "-v" ]; then exit 0 fi +# Check if we're being autolaunched, and this user explicitly does not want it. +if [ "$0" = "/etc/profile.d/$PKG.sh" ] && [ -r "$HOME/.$PKG/disable-autolaunch" ]; then + exit 0 +fi + # Sanitize the environment byobu-janitor --force diff --git a/usr/bin/byobu-launcher b/usr/bin/byobu-launcher new file mode 100755 index 00000000..de4589ab --- /dev/null +++ b/usr/bin/byobu-launcher @@ -0,0 +1,24 @@ +#!/bin/sh -e +# +# byobu-launcher - conditionally launch byobu +# Copyright (C) 2010 Canonical Ltd. +# +# Authors: Dustin Kirkland +# +# 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, version 3 of the License. +# +# 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, see . + +PKG="byobu" + +[ -r "$HOME/.$PKG/disable-autolaunch" ] && exit 0 + +exec /usr/bin/$PKG diff --git a/usr/bin/byobu-launcher-install b/usr/bin/byobu-launcher-install index 30385601..5dc932ab 100755 --- a/usr/bin/byobu-launcher-install +++ b/usr/bin/byobu-launcher-install @@ -28,6 +28,7 @@ install_launcher() { echo "$launcher_line" >> "$dest" # Hush login, since byobu will handle motd printing touch "$HOME"/.hushlogin + rm -f "$HOME/.$PKG/disable-autolaunch" } # Sanitize the environment diff --git a/usr/bin/byobu-launcher-uninstall b/usr/bin/byobu-launcher-uninstall index 2001a2e4..dcf63431 100755 --- a/usr/bin/byobu-launcher-uninstall +++ b/usr/bin/byobu-launcher-uninstall @@ -26,8 +26,9 @@ remove_launcher() { sed -i "/$PKG-launcher$/d" "$dest" sed -i "/screen-launcher$/d" "$dest" fi + touch "$HOME/.$PKG/disable-autolaunch" # the install disabled motd printing; re-enable - rm "$HOME"/.hushlogin 2>/dev/null || true + rm -f "$HOME"/.hushlogin } for i in ".profile" ".bashrc" ".bash_profile" ".zprofile"; do