######################################################
### beep.sh
Make a simple bell sound.
If this does not work in your terminal, it is possible you need to enable the kernel mod:
sudo modprobe pcspkr

To enable this permanently on a RHEL-like system:
echo "pcspkr" > /etc/modules-load.d/pckspkr.conf

For an alternate beep noise of your choice:
dnf -y install pulseaudio-utils
echo "paplay /usr/share/sounds/freedesktop/stereo/dialog-error.oga" > beep.sh

######################################################
### bounce.sh
Restart items. Currently supports network cards, network shares, and systemd services. Only bounce one type of item, but can accept multiple of that type. This means do not bounce eno1 and /mnt/cifsshare1 in the same command.

usage: bounce.sh [-duV] [-D delay] [-n|-d|-s] [object1 ...]
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -D delay   DELAY in seconds between down and up cycles. Default is "${DELAY}"
 object1... Item to restart. Supported items include network cards, network shares, and systemd services.
 -n|-d|-s   Optional flags that provide nice autocomplete options.

Examples:
bounce -n eno1
bounce -d /mnt/foo
bounce ntpd.service

######################################################
### bup.sh
Backup (bup) a file to file.YYYY-MM-DD.serialnumber.
If you provide a directory at the end, bup all named files to that output directory.

usage: bup.sh [-udp] [<infile1> <infile2> <infile3> ...] [<outdir>]
 -u usage    Show this usage block.
 -d debug    Show parameters while being parsed. Prevents actual operation.
 -p pwd      For all files, bup each file to PWD. Ignored if <outdir> is specified.
 infile1     Required. This is a file to bup.
Notes:
 If the last object name passed is a directory, it will be used to store each
bupfile. Otherwise, the script will bup each file to its own location.

Examples:
bup foofile1  # will output foofile1.2017-07-19.01
bup recentlymodified.txt # if recentlymodified.txt.2017-07-19.02 exists, will create recentlymodified.txt.2017-07-19.03

Limitations:
Only counts up to 20. If you are trying to preserve history of a configuration more than 20 times in a day, please look into a proper version control system.

######################################################
### changelog.sh
A simple and probably incomplete attempt to make it possible to convert rpm spec %changelog formats into the debian maintainer script changelog formats and vice versa.

usage: changelog.sh [-duV] [-f] [-i infile] [-o outfile] [ rpm | (deb|dpkg) ] [ -p packagename ]
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -f force   Just overwrite the relevant parts of the outfile, regardless of type.
 -i infile  File to be converted. 'stdin' is available as an option.
 -o outfile Output file. If a .spec, replace any %changelog present. Default is stdout.
 -p packagename Name to use if output is deb. Can be determined if an understandable filename.

######################################################
### ctee.sh
Displays output to terminal and still includes the color ANSI escape codes, while sending on to the pipe stdout the output excluding the color ANSI escape codes.
This script is useful for when a process contains colorized output and you want to keep it colorized, but capture into a log just the plain text.

usage: some-program | ctee.sh [-aduV] [outfile1]
 -a append  Append to given file, do not overwrite.
 -d debug   Throws error. For debugging, edit value \$devtty in the script.
 -u usage   Show this usage block.
 -V version Show script version number.
This script operates tee and preserves color on the output while sending uncolored output to the file.
Sometimes a program needs to be used with unbuffer to display color to a pipe.

Examples:
time unbuffer ansible-playbook example.yml | ctee /var/log/ansible-plays.log

######################################################
### dnskeepalive.sh
Service that rotates dns server settings based on which name servers are responding.

It is not intended that the user call this script manually. A systemd service is installed by the rpm package and is titled dnskeepalive.service.

Configuration is possible by default in file /etc/sysconfig/dnskeepalive.

usage: dnskeepalive.sh [-duV] [-c conffile]
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -c conffile Specify config file. If not provided, use default values for everything.
 -1 one     Run dnskeepalive just once.

Examples:
systemctl start dnskeeplive && systemctl enable dnskeepalive
/usr/bin/dnskeepalive -1 -c /etc/dnskeepalivecustom.conf

######################################################
### enumerate-users.sh
This script lists all users it can find on the system, based on /etc/passwd and sssd. Alternatively it will list the homedirs for all those users.
It is used primarily in rpm scriptlets or deb maintainer scripts to perform actions for each user, such as update the mimetype info.

Examples:

for user in $( /usr/bin/enumerate-users ) ;

######################################################
### fl.sh
Wrapper for 'find | xargs ls -dl'

Not really in use anymore, but might be of some helpfulness somewhere.

usage: fl.sh [-ud]
 -u usage   Show this usage block.
 -d debug   Show what search would be used. Prevents actual operation.

######################################################
### framework.sh
Framework is a library for shell scripts. It will never be needed on its own.

Its documentation is in a separate file named FRAMEWORK.txt

######################################################
### ftemplate.sh
Ftemplate is the basis for any new scripts, because it is called by the newscript.sh script. It is also available for manual manipulation/duplication.

A better description is included in the FRAMEWORK.txt document.

######################################################
### host-bup.sh
Provides a nice way to simplify backing up the configuration files on a system.

Configure the default file /etc/installed/host-bup.conf to resemble this example:

    [hostbup:main]
    hostname=storage1.ipa.smith122.com
    tar_out_file=/mnt/public/Support/Systems/storage1/config.storage1.$( date "+%Y-%m-%d" ).tgz
    script_count=1
    script_1_cmd=/usr/bin/dli . > /tmp/dnf.installed.log
    dryrun=0
    
    [hostbup:files]
    # this file
    /etc/installed/host-bup.conf
    /tmp/dnf.installed.log  # dnf list installed
    # host changelog
    /etc/installed/storage1.log
    # apache
    /etc/httpd/conf/httpd.conf

With the above host-bup.conf, you can call:
/usr/bin/host-bup
And the script will tar and gzip all the files from the [hostbup:files] section in the ${tar_out_file} file.
Any commands in the script_X_cmd variables up to the value of script_count will be executed.

See example file /usr/share/bgscripts/examples/host-bup.conf.example

NOTICE! For safety, you must have the correct hostname in the host-bup.conf file. This is to protect the system from trying to use a list of files and actions meant for a different host.

usage: host-bup.sh [-duV] [-c conffile]
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -c conf    Select conf file. Default is ${conffile}.
 -n dryrun  Only perform debugging. Do not execute scripts or build tgz.
 -f force   Ignore hostname mismatch.
host-bup.sh is designed to easily bup the config files on a host.
Debug level 5 and above will not execute the script_1_cmd values.

######################################################
### lecho.sh
Log Echo. This script takes the parameters given to out and prepends the timestamp and username and hostname.

This script is useful when called in other scripts, to provide an easily greppable format of the date and time.

Examples:
lecho "job started"
Output:
[2017-07-19 20:20:14]bgstack15@woof-01: job started

######################################################
### newscript.sh
Generates a new script with the provided name and fills in a number of variables, from the ftemplate file.

A better description is included in the FRAMEWORK.txt document.

######################################################
### orig-send.sh
Original version of send.sh


######################################################
### plecho.sh
Pipe Log Echo, which does the log echo action to the standard input.

When you have standard input which you want timestamped, use plecho.

Examples:
ls -lZ /etc/krb5.conf | plecho
Output:
[2017-07-19 20:25:06]bgstack15@woof-01: -rw-r--r--.1 root root system_u:object_r:krb5_conf_t:s0 575 Jul 13 20:50 /etc/krb5.conf

######################################################
### send.sh
Send.sh was a sendmail wrapper originally written for an AIX environment. This script is almost obsolete in a GNU environment with the mailx command.

The redeemable feature of send.sh is that it provides options for sending messages in fixed-width html format.  The script will detect when a flaglessval (parameter without a leading dash and not the option of such a parameter) is either a filename or an email address.
Accepts standard input as well.

For when you want to use a different smtp server, use mailx:
echo "${message}" | mailx -r 'Pretty name <bgstack15@gmail.com>' -S smtp='smtp.example.com:25' -s 'subject line example' me@example.com

For when you want to send an attachment, use mailx:
mailx -a attachment.txt -s 'includes attachment' me@example.com < message.txt

usage: send.sh [-duV] [-h|-H] [-s "subject line"] [ -f <fromemail> ] <infile> [email1 ...]  
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -h html    Add html headers, and edit the contents to include the <html> tags.
 -H         Add html headers, and assume content is already html format.
 -f from    Set value of From: header
 <infile>   The file to mail. Required if stdin not provided.
 email1...  Overrides default email addresses. Default is ${defaultemail}
Accepts stdin and will use the first line as the subject if not specified.

Examples:
If you have file dnf.installed.log and wish to email it in a fixed-width message, use this command:
send -h -s 'dnf install gnome-desktop' dnf.installed.log destination@example.com
Send standard input from a particular email to a destination email address.
ls -l | send -f 'Pretty name <bgstack15@gmail.com>' -s 'Listing of pwd files' destination@example.com

######################################################
### shares.sh
Shares.sh performs tasks on network mounts, including remounting and touching (to keep alive).

This script can be used to touch (without creating) a file on a filesystem. By using a network mount every so often, it keeps the share from going stale.

usage: shares.sh [-duV] [-r|-k] [-a] [-t <type>] [/mounted/directory [ ... ]]
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -r remount Remount shares
 -k keepalive Touch shares to keep them from timing out
 -a all     All shares. Can be limited with -t. Default behavior if no directories provided.
 -t <type>  Only this type of share. Needs -a flag.

An example cron job is provided at /usr/share/bgscripts/examples/shares-keepalive.cron.
*/3	*	*	*	*	root	/usr/bin/shares --all --keepalive 1>/dev/null 2>&1

To install as a cronjob, just copy the file to /etc/cron.d/.
sudo cp -p /usr/share/bgscripts/examples/shares-keepalive.cron /etc/cron.d/

Examples:
To remount all cifs shares:
shares -r -a -t cifs
To touch certain directories to keep the connection from going stale:
shares -k /mnt/cifs1 /mnt/cifs2

######################################################
### title.sh
Uses the escape commands to adjust the terminal window.
Observe that this script only does the basic printf command. It is likely that the PROMPT_COMMAND variable also includes a command that manipulates the terminal title.
To modify the title on a 'permanent' basis, use the permtitle alias from the bgscripts.bashrc file, which is described in the BGSCRIPTS-BASHRC.txt document.

Examples:
title 'running backup job'; ./backup-script.sh --incremental; beep

######################################################
### toucher.sh
Toucher provides a simpler way to touch, chmod, chown, restorecon a file.

In many scriptlet copy-paste segments I generate a file in preparation for catting content into it. To prepare a file, I might run:
tf=/etc/krb5.conf
touch "${tf}"; chmod 0600 "${tf}"; chown root:root "${tf}"; restorecon "${tf}"

To make this process take fewer characters to type, I wrote this toucher script.

Examples:
tf=/home/developers/example.txt
toucher 0644 bgstack15:bgstack15 "${tf}"
cat <<EOF > "${tf}"
Contents of the example file go here.
EOF

######################################################
### monitor-resize.sh
Monitor-resize is a daemon that monitors the X displays and tells them to resize if the display size has changed. This is useful on virtual machines.
The program is written in Bourne shell, and uses /proc filesystem to collect information it needs. This tool represents a new architecture in my repertoire: a master-child forking process with control via signals.

Use monitor-resize by enabling and starting monitor-resize.service.

######################################################
### mp4tomp3.sh
mp4tomp3.sh wraps around the ffmpeg (or avconv) utility. It accepts an mp4 file and calculates the highest bitrate to convert the audio to mp3 for you, and then converts it.

Examples:

./mp4tomp3.sh "Ace of Base - The Sign.MP4"


######################################################
### gui/screensize.sh
screensize.sh shows the width and height of the main X display. Unfortunately if you invoke it from a shell not associated with a display, simply adding DISPLAY=:0 still does not work. Further research is needed to get it to work correctly.

######################################################
### sizer.sh
sizer.sh accepts a directory as a parameter. It then counts the size on disk of the files, grouped by extension.
An improvement to be made is to count the files that have no extension.

Example:

./sizer.sh /mnt/public/Music

######################################################
### work/cladu.sh
CLADU stands for Convert Local to AD User. If a user exists as a local user, and in sssd, and can authenticate in sssd as determined by userinfo.sh below, the local user will be removed and the homedir will change owners to the sssd uid. Also, an email will be sent to the admin and a report left behind in the user directory.
It accepts multiple users on the command line. It will safely skip any users it cannot convert and will indicate why.

Example:

./cladu.sh rpatton hlovell ybrown

######################################################
### work/list-active-repos.sh
This script lists the repos that do not have an 'enabled=0' because I do not understand the yum repomanage commands.

######################################################
### work/list-vnc-sessions.sh
list-vnc-sessions.sh displays all the current Xvnc sessions, with the intention to make it easier to find your existing one so you can reconnect.

######################################################
### work/sslscanner.sh
sslscanner.sh accepts a parameter of a URL or a hostname:port combo and executes an openssl s_client --connect. It outputs a summary of the ssl certificates served.
This is useful when you are investigating why the certificate is not trusted: Are you getting the cert you expect?

######################################################
### work/userinfo.sh
userinfo.sh returns a few atomic pieces of information about a user:

Example:

./userinfo.sh bgstack15
user: bgstack15
getent: YES
chage: expired,expired,expired,2018-05-15,7,90,7
getent_type: sss
can_ssh: YES
can_sss: YES

######################################################
### work/allow-group.sh
Allow-group makes it a single command to configure sshd and sssd to allow a named group. All sorts of options exist for this script, either as parameters or as environment variables or entries in a config file.

usage: allow-group.sh [-duV] [-v|-s] [-a|--noapply] [-c conffile] [--sshd_config sshd_config] [--sssd_conf sssd.conf] [--all] [--ssh] [--sssd] <--allow|--deny> group1 [ group2 ... ]
version ${allowgroupversion}
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -v verbose|noverbose|silent Set AG_VERBOSE
 -a apply|noapply  Set AG_APPLY
 -c conf    Read in this config file.
 --all|noall    Aliases of "--ssh --sssd" and "--nossh --nosssd"
 --ssh|nossh    Update sshd config
 --sssd|nosssd  Update sssd config
 --allow|deny   Add or remove the group from the permissions list.
 --sshd_config  Set AG_SSHD_CONFIG_FILE
 --sssd_conf    Set AG_SSSD_CONF_FILE
Environment variables (parameters override environment variables)
AG_ACTION=allow|deny If allow, add group to affected files. If deny, remove group.
AG_SSHD_CONFIG_FILE  Default is /etc/ssh/sshd_config
AG_SSSD_CONF_FILE    Default is /etc/sssd/sssd.conf
AG_SSH        If truthy, affect sshd. Default is yes.
AG_SSSD       If truthy, affect sssd. Default is yes.
AG_APPLY      If truthy, save changes and reload daemons. Default is yes.
AG_VERBOSE    Show the "allow" lines from the config files, regardless of changes that might be made
AG_MODCONF    Location of modconf.py dependency

Examples:

/usr/bin/allow-group.sh --sssd --sshd --allow linux_admins nginx_dev

######################################################
### work/access_like.sh
access_like.sh makes it easy to set up a new user that already exists to match the groups and permissions of another existing user. This task was originally an ansible playbook but was converted to shell format for permanent installation and local use without dependence on an ansible server.

Exactly one likeuser is required. Any number of users to set up may be passed as parameters.

usage: access_like.sh [-duV] [-n] [-c conffile] [-l <likeuser>] <thisuser1> [ <thisuser2> ... ]
version ${access_likeversion}
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -c conf    Read in this config file.
 -l likeuser  Set AL_LIKEUSER
 -n dryrun  Set AL_DRYRUN
 -a apply   Unset AL_DRYRUN
 -h --nh    Set or unset AL_HANDLERS
Environment variables:
AL_LIKEUSER   Match the permissions and access of this user
AL_DEBUG [0-10]  Set debug value to a number, like -d flag.
AL_DRYRUN     If truthy, do not apply changes. Just report.
AL_HANDLERS   If truthy, the script will restart affected daemons: sshd, sssd. Default is 1.
Return values:
 0 Normal
 1 Help or version info displayed
 2 Count or type of flaglessvals is incorrect
 3 Incorrect OS type
 4 Unable to find dependency
 5 Not run as root or sudo
 6 Likeuser is invalid
Debug levels:
 0 Normal operation
 1 Show commands run
 2 Show tasks skipped because they are already compliant
 4 Show changes made to config files
 5 Show all input AL_ variables

######################################################
### work/kinit-host.sh
kinit-host makes it easy to request a kerberos ticket using the host keytab. Normally one can run this command:

kinit -k "$( hostname -s | tr '[[:lower:]]' '[[:upper:]]' )\$"

But this command does that for you, without having to type all that.

usage: kinit-host.sh [-duV] [-c conffile] [-u --upper|-l --lower] [-D --dollar|-n --no-dollar] [-f --fqdn|-s --short] [--hostname <HOSTNAME>] [--domain <DOMAIN>] [-q --silent] [--kinit </opt/bin/kinit>] [-N --dry-run]
version ${kinithostversion}
 -d debug   Show debugging info, including parsed variables.
 -u usage   Show this usage block.
 -V version Show script version number.
 -c conf    Read in this config file.
Environment variables:
KH_UPPER [0|1]  Use (0) lowercase or (1) uppercase name in request. Default is 1
KH_FQDN [0|1]   Use (0) shortname or (1) fqdn (hostname.example.com). Default is 0
KH_DOLLAR [0|1] Append $ dollar sign to end. Default is 1
KH_HOSTNAME     If left blank, will use \$( hostname -s )
KH_KRB5_CONF    Use this krb5.conf file. Default is /etc/krb5.conf
KH_KINIT        Use this binary for kinit request. Default is /bin/kinit
KH_DOMAIN       Use this domain for the fqdn action. Default is derived from KH_KRB5_CONF file.
KH_SILENT [0|1] Suppress kinit errors. Default is 0
KH_DRYRUN [0|1] Suppress action. Default is 0
Debug levels:
 1 kinit request
 5 all KH_ environment parameters
Return values:
 0 Normal
 1 Help or version info displayed
 2 Count or type of flaglessvals is incorrect
 3 Incorrect OS type
 4 Unable to find dependency
 5 Not run as root or sudo
Or alternatively will return the value from the kinit execution

######################################################
### shldap.sh
Shldap, pronounced "shell-dap," is my shell library for ldap functions. It provides some functions that read and write attributes to ldap, and the associated functions necessary for kerberos authentication.

To use in a script, you need to load the dependency:

# load dependecy: shldap
. "${GL_SHLDAP}"
GL_SHLDAP_MINIMUM=20181114
if ! test $( echo "${SHLDAP_VERSION}" | tr -dc '[[:digit:]]' ) -ge ${GL_SHLDAP_MINIMUM} ;
then
   ferror "${scriptfile}: 4. Insufficient version of shldap found: ${GL_SHLDAP} ${SHLDAP_VERSION}. Need >= ${GL_SHLDAP_MINIMUM}. Aborted."
   exit 4
fi

A basic write workflow:
read_workflow() {
   # 1. prepare keytab
   get_host_keytab "${GL_KINIT_HOST_SCRIPT}" "${GL_KLIST_BIN}" "${GL_KRB5CC_TMPFILE}"

   # 2. read attribute from AD
   GL_location="$( get_attrib_from_ldap "${GL_LDAPSEARCH_BIN}" "${GL_LDAPSEARCH_FLAGS}" "${GL_LDAPSEARCH_FILTER}" "${GL_ATTRIB_LOCATION}" "${GL_LDAPCONF}" "${GL_KRB5CC_TMPFILE}" )"
   fistruthy "${GL_VERBOSE}" && echo "${GL_location}"
}

A basic read workflow:
write_workflow() {
   # 1. calculate value
   GL_location="value"
   fistruthy "${GL_VERBOSE}" && echo "${GL_location}"

   # 2. prepare host keytab
   get_host_keytab "${GL_KINIT_HOST_SCRIPT}" "${GL_KLIST_BIN}" "${GL_KRB5CC_TMPFILE}"

   # 3. write to ad
   update_ldap "${GL_LDAPSEARCH_BIN}" "${GL_LDAPSEARCH_FLAGS}" "${GL_LDAPSEARCH_FILTER}" "${GL_LDAPSEARCH_UNIQUE_ID}" "${GL_LDAPCONF}" "${GL_KRB5CC_TMPFILE}" "|" "${GL_ATTRIB_LOCATION}" "${GL_location}" "${GL_LDIF_TMPFILE}" "${GL_LDAPMODIFY_BIN}" "${GL_LDAPMODIFY_FLAGS}" "${GL_TEST}" "${GL_TMPFILE1}"

}

The functions in this library take a large number of parameters to operate correctly. Example values include:
define_if_new GL_KINIT_HOST_SCRIPT /usr/bin/kinit-host
define_if_new GL_KLIST_BIN /usr/bin/klist
define_if_new GL_KINIT_BIN /usr/bin/kinit
test -z "${GL_KRB5CC_TMPFILE}" && GL_KRB5CC_TMPFILE="$( TMPDIR="${GL_TMPDIR}" mktemp )"
test -z "${GL_LDIF_TMPFILE}" && GL_LDIF_TMPFILE="$( TMPDIR="${GL_TMPDIR}" mktemp )"
test -z "${GL_TMPFILE1}" && GL_TMPFILE1="$( TMPDIR="${GL_TMPDIR}" mktemp )"

define_if_new GL_LDAPSEARCH_BIN "/usr/bin/ldapsearch"
define_if_new GL_LDAPSEARCH_FLAGS "-LLL -O maxssf=0 -o ldif-wrap=300 -Y gssapi"
define_if_new GL_LDAPSEARCH_FILTER "(cn=$( hostname -s )*)"
define_if_new GL_LDAPSEARCH_UNIQUE_ID "dn"
define_if_new GL_ATTRIB_LOCATION "location"
define_if_new GL_LDAPMODIFY_BIN "/usr/bin/ldapmodify"
define_if_new GL_LDAPMODIFY_FLAGS "-O maxssf=0 -Q -o ldif-wrap=300 -Y gssapi -f"
define_if_new GL_LDAPCONF "/etc/openldap/ldap.conf"
define_if_new GL_KERBEROS_USER "machine"

######################################################
### learn-used-grub-entry
learn-used-grub-entry shows which grub menuentry will be used at next boot. It interpretes the grub saved value, and the GRUB_DEFAULT value. With no parameters or environment variables set, it will simply display the name of the entry. Using a parameter or setting environment variable LUGE_OUTPUT will show different values.

set $1 or LUGE_OUTPUT to | effect
-------------------------+--------------------------------
kernel                   | show used kernel image
initram                  | show used initram file
number                   | show "saved" or number of entry used

Just remember that the menuentry items are zero-indexed in grub.cfg.

/usr/bin/learn-used-grub-entry kernel
/vmlinuz-4.1.12-93.12.4.el7.x86_64

######################################################
### istruthy
This script is the function fistruthy from framework but moved to its own script.

usage:
istruthy "${myvar}" && echo "myvar is some form of truthy, such as (Y|yes|1|on)"

######################################################
### drillup
This script shows you the long listing of the provided directory, and all of its parents back to the root directory. This output is useful when troubleshooting user access to directories in customized situations.

Examples:
drillup $( readlink -f . )
dr-xr-xr-x. 17 root    root          224 Apr 12 10:01 /
drwxr-xr-x.  7 root    root           91 May 10 16:21 /home
drwx------.  9 bgstack15 bgstack15  279 May 28 16:52 /home/bgstack15
drwx------.  8 bgstack15 bgstack15   89 May 28 16:28 /home/bgstack15/rpmbuild
drwx------.  3 bgstack15 bgstack15   23 May 28 16:28 /home/bgstack15/rpmbuild/SOURCES
drwx------.  5 bgstack15 bgstack15  148 May 28 16:52 /home/bgstack15/rpmbuild/SOURCES/bgscripts
drwx------.  4 bgstack15 bgstack15   44 May 28 16:51 /home/bgstack15/rpmbuild/SOURCES/bgscripts/src
drwx------.  4 bgstack15 bgstack15   30 May 28 16:28 /home/bgstack15/rpmbuild/SOURCES/bgscripts/src/usr
drwx------.  2 bgstack15 bgstack15 4096 May 28 16:46 /home/bgstack15/rpmbuild/SOURCES/bgscripts/src/usr/bin

######################################################
### xscreensaver-watch
This script will listen to the running xscreensaver daemon and run local scripts when xscreensaver blanks or unblanks the screen.
This script will run unqualified command `on-xsw-lock` and `on-xsw-unblank`, so set XSW_PATH in /etc/sysconfig/xscreenaver-watch to affect which scripts will be executed. This is designed to let individual users control what will happen when their screensaver unlocks.
A sample script is included, that is useful when using wicd to manage wired network connections. To use it, take the following actions.

    mkdir -p ~/bin
    ln -s /usr/libexec/bgscripts/connect-if-disconnected ~/bin/on-xsw-unblank

######################################################
### make-dsc-for-obs
This script is designed to be used in a package tarball dir where a debian/ tree exists. It can be run from a debian/rules file as part of the debuild process. It will take the generated dsc file and generalize it a little and place it in the debian/ tree, so that the source control can pick up the dsc file. This facilitates my process for building dpkgs in obs.
Define `APPNAME`, and run the script from the package top directory.

