From: Fred T. Hamster Date: Tue, 14 Nov 2017 21:14:42 +0000 (-0500) Subject: Merge branch 'dev' of feistymeow.org:feisty_meow into dev X-Git-Tag: 2.140.100^2~16^2 X-Git-Url: https://feistymeow.org/gitweb/?a=commitdiff_plain;h=0f209735e5947001e6438a17c05c4ac052d23866;hp=0def2144aed95b333fb37fbec3b121e1c22b2f55;p=feisty_meow.git Merge branch 'dev' of feistymeow.org:feisty_meow into dev --- diff --git a/infobase/fortunes.dat b/infobase/fortunes.dat index 4b508630..1f462d80 100644 --- a/infobase/fortunes.dat +++ b/infobase/fortunes.dat @@ -43018,3 +43018,11 @@ elements into enlightenment by means of that connection.   ~ Never admit defeat. Just move the front. -- fred t. hamster +~ +down came eddy from his heady, +where he dwells often unsteady, +you see he gets so high, +mind expanded to sky; +real world grokking just not ready. + -- fred t. hamster + diff --git a/infobase/sounds/were_sorry_youre_a_spammer.mp3 b/infobase/sounds/were_sorry_youre_a_spammer.mp3 new file mode 100644 index 00000000..57f1eaf6 Binary files /dev/null and b/infobase/sounds/were_sorry_youre_a_spammer.mp3 differ diff --git a/production/feisty_meow_config.ini b/production/feisty_meow_config.ini index de81f33b..8e74eaac 100644 --- a/production/feisty_meow_config.ini +++ b/production/feisty_meow_config.ini @@ -3,7 +3,7 @@ # specifies the version of the code that is being constructed here. major=2 minor=140 -revision=98 +revision=99 build=420 # specifies the remainder of the version record info. diff --git a/production/sites/cakelampvm.com/docs/manual/cakelampvm_guide_v002.html b/production/sites/cakelampvm.com/docs/manual/cakelampvm_guide_v002.html new file mode 100644 index 00000000..610b4564 --- /dev/null +++ b/production/sites/cakelampvm.com/docs/manual/cakelampvm_guide_v002.html @@ -0,0 +1,285 @@ + + + + + Cake LAMP VM Documentation + + +

The cakelampvm VM:
+ Configuration and Usage

+

By Chris Koeritz

+

Vintage: cakelampvm v002    + Updated: 2017-11-10

+
+

Basic info for the guest VM

+ +

How to set up virtualbox for your host PC

+
    +
  1. Download and install virtualbox: + https://www.virtualbox.org/wiki/Downloads
  2. +
  3. Install the extension pack for virtualbox: This provides USB drivers + and other features.  This is installed on virtualbox itself, not on + the guests.
  4. +
      +
    1. Download the extension pack at + https://www.virtualbox.org/wiki/Downloads
    2. +
    3. Stop any running virtualbox vms.
    4. +
    5. Close virtualbox control panel.
    6. +
    7. Double-click on the downloaded extensions package (in a file + explorer) and virtualbox should install it.
    8. +
    +
  5. Run the virtualbox control panel.
  6. +
  7. Download the cakelampvm guest vm package and unzip it.  Store the + unzipped version in some appropriate place where you want the virtual + machine to reside on your host's hard drive.
  8. +
  9. Add the guest VM to your list of VMs.  From the virtualbox menus, + choose the "Machine" menu and select "Add".  Point the selector + dialog at the cakelampvm folder you created above and open the + cakelampvm.vbox file.
  10. +
  11. Now the cakelampvm should show up in the list of virtual + machines.  Before starting it, perform the following network + configuration sections.
  12. +
+

Configure the Host-Only network on virtualbox

+

Configuring host-only networking for the VM makes the VM completely local + to your machine.  The cakelampvm will not be accessible on the + internet or from the LAN, and can only be accessed by your host PC.

+
    +
  1. Go to virtual box "Preferences" (global preferences, not for a + specific vm).
  2. +
  3. Click on the "Network" tab.
  4. +
  5. Choose the "Host-only Networks" tab from within "Network".
  6. +
  7. Click the plus icon to add a new host-only network.
  8. +
  9. Set the "Adapter" parameters:
    + IPv4 Address: 10.28.42.1
    + IPv4 Network Mask: 255.255.255.0
    + IPv6 Address: (leave blank)
    + IPv6 Prefix Length: 0
    + Virtualbox will fill in the other details like so:
    +

    host only network adapter

    +
  10. +
  11. Set the "DHCP Server Settings" to disabled, e.g.
    + host only dhcp
    + This is disabled because we will be using statically assigned addresses + for convenience and stability.
  12. +
+

Additional information on host-only (and other) network adapter types is + at: https://www.virtualbox.org/manual/ch06.html#network_nat_service
+

+

Configure the Nat Network on virtualbox

+
    +
  1. Go to virtual box "Preferences" (global preferences, not for a + specific vm).
  2. +
  3. Click on the "Network" tab.
  4. +
  5. Choose the "Nat Networks" tab from within "Network".
  6. +
  7. Click the plus icon to add a new host-only network.
  8. +
  9. Set the "NAT Network Details" parameters:
    + Network Name: NatNetwork
    + Network CIDR: 10.0.2.0/24
    + Supports DHCP: checked
    + Supports IPv6: optionally checked
    + These are my settings, with IPv6 left disabled:
    + nat net config
  10. +
+

Using the guest VM's DNS services

+

The cakelampvm has been set up to provide a DNS server which will answer + name requests for all of the sites that the VM hosts.

+

To use the cakelampvm DNS, modify your host operating system network + configuration by adding or changing the DNS server to use the guest VM's + DNS service.  This is available at the local address + 10.28.42.20.  The DNS server can be tested with nslookup, dig and + other tools.

+

Note that the cakelampvm DNS should be listed first, if one intends to + override any DNS names that actually exist out on the internet.

+

If the DNS server is properly set up, then these ping commands should get + answering responses:

+
ping cakelampvm.com
+
ping defaultcake.cakelampvm.com
+
ping mapsdemo.cakelampvm.com
+

Editing files on the guest VM from the host

+

On the host computer, look for the guest vm as a networked computer + called cakelampvm.  This should provide some network shares using + Microsoft SMB protocol, and they can be attached to using the "developer" + user and its password.

+

On windows, one may want to mount this network location as a drive letter + for easier access.

+

Currently, the root of all web servers is exposed as "www".  Editing + the files in those folders requires ownership by the developer user.  + Currently the defaultcake server is owned by developer.

+

One should be able to create a new directory in the www folder owned by + the developer user over the network also, which can be used for creating + new projects.  However, there is a config issue in the current vm + (v001) about this; to fix, run this command on the guest vm as the + developer user:

+
sudo chmod g+w /var/www
+

Afterwards, the www folder should allow the developer user to create new + folders at will.

+

Accessing files on the host PC from the guest VM

+

If you want to share a folder from the host to the guest, perhaps for + driver updates or other conveniences, then make the share with these + steps:

+
    +
  1. Create a folder on the host that is to be shared.
  2. +
  3. Right-click on the vm in virtualbox manager and choose "Settings".
  4. +
  5. In the "Shared Folders" tab of the settings, go to "Machine Folders".
  6. +
  7. Click the folder plus icon to create a new share.
  8. +
  9. Fill in the "Folder Path" on the host PC to the folder that will be + shared, and give it a name for the guest.  We assume the folder + name will be "myshare".
  10. +
  11. On the guest vm, run the following commands to mount the share:
    +
    mkdir ~/shared    # for the guest's version of the shared folder
    +
    sudo mount -t vboxsf myshare ~/shared    # mount the vm's share name onto the folder on the vm.
    +
  12. +
+

Adding a new website and domain on the guest VM

+

To add a new website, you will need to pick one of the DNS options below + (A or B) depending on how you want to name the site.  After the DNS + is updated, then follow the section after for creating a new apache conf + file.

+

Assuming one has created a new folder in "www" called "greatsite", then + the new web site can be brought online on the vm with one of the following + options.

+

DNS Option A: Using a sub-domain in the cakelampvm.com domain

+ Connect to the cakelampvm via ssh as the developer user, e.g.: ssh + developer@cakelampvm.com +

Execute the following command to edit the DNS file for the cakelampvm + domain:

+
sudo vi /etc/bind/cakelampvm.com.conf
+

Add a stanza for the new site at the end of this file:

+
greatsite.cakelampvm.com    IN A    10.28.42.20
        IN HINFO "linux server" "ubuntu"
+

Restart the DNS server: sudo service bind9 restart

+

Afterwards, pinging greatsite.cakelampvm.com should work from either the + guest or the host.

+

DNS Option B: Using an entirely new domain for the site

+

Similar procedure to above, but we will create a new file for the new + domain and add it to the bind directory.  For this example, we will + create a file called /etc/bind/greatsite.tv.conf for our new domain + greatsite.tv with these contents:

+
$TTL 1W
@       IN SOA          @       fred.cakelampvm.com. (
                        2017100801      ; serial
                        2H              ; refresh
                        8M              ; retry
                        14D             ; expiry
                        6H )            ; minimum

        IN NS           ns.cakelampvm.com.
        IN MX   10      mail.cakelampvm.com.

# main domain for machine.
greatsite.tv.                 IN A            10.28.42.20
                              IN HINFO        "linux server" "ubuntu"
+ The gnarly prefix stuff above the "greatsite.tv." listing establishes + configuration info for the new domain.  This file relies on the + existing cakelampvm.com infrastructure in DNS, such as the "ns" host, which + is the domain's name server. +

Now that the config file is in place, edit "named.conf.local" to add the + new file by adding this bit of configuration at the end:

+
zone "greatsite.tv" in {
        file "/etc/bind/greatsite.tv.conf";
        type master;
        allow-query { any; };
};
+

Restart the DNS server: sudo service bind9 restart

+

Afterwards, pinging greatsite.tv should work from either the guest or the + host.

+

Create a new apache configuration file and load it

+

Start with the following template file for the new website, and modify it + for the appropriate host name:

+
<VirtualHost *:80>
    ServerName greatsite.cakelampvm.com
    ServerAlias greatsite.cakelampvm.com *.greatsite.cakelampvm.com
    DocumentRoot /var/www/greatsite
    ErrorLog ${APACHE_LOG_DIR}/greatsite.cakelampvm.com-error.log
    CustomLog ${APACHE_LOG_DIR}/greatsite.cakelampvm.com-access.log combined
    Alias /statistics "/var/www/webwork.repository/webwork/maps_demo/webroot/statistics"
    Include /etc/apache2/conf-library/basic-options.conf
    Include /etc/apache2/conf-library/rewrite-enabling.conf
</VirtualHost>
+

The above example is pre-modified for DNS Option A above, the + greatsite.cakelampvm.com name.  Switching all of those to + "greatsite.tv" instead would support DNS option B.

+

Copy that file into /etc/apache/available-sites under an appropriate + name, which here we will call "greatsite.conf".

+

Tell apache to use the new file:

+
a2ensite greatsite.conf
+

Finally, restart apache to get it to begin serving the site:

+
sudo service apache2 restart
+

Test the new web site

+

Given the configuration above, your host PC should now be able to access + the new website.

+

To test this, first try pinging the hostname, e.g.: ping + greatsite.cakelampvm.com or ping greatsite.tv

+

Then, if there are responses to the ping, it means the DNS is + working.  If there are no responses, check the instructions in the + above DNS option section.

+

Once the DNS is working, one can try browsing to the site at: + http://greatsite.cakelampvm.com or http://greatsite.tv (depending on the + DNS option chosen).

+

If the site is not showing up properly, try examining the apache logs for + error messages that can be corrected.  The log files are stored in + /var/log/apache2 and are generally named after the website.

+

Configuring the guest VM

+

The guest VM should already be set up appropriately.  These steps + are provided for reference and updates.

+

Set up virtualbox guest additions for the VM

+

** note for v001 of cakelampvm: the below steps are still needed on the + shipped image.

+

This procedure is needed if the guest provides an older or incompatible + version of the guest additions (which have already been installed on the + guest vm).  It may also be necessary when a new version of the guest + additions becomes available.

+
    +
  1. To install the guest additions, open the guest VM and have its window + in focus.
  2. +
  3. Choose the "Devices" menu and select "Insert Guest Additions CD + Image".  This will mount the CD's ISO image on the VM.
  4. +
  5. On the guest VM, it may be necessary to mount the CD image that's now + available:
    + sudo mount /dev/sr0 /media/cdrom
  6. +
  7. Since the VM currently has no windowing system installed, one must + start the Guest Additions install manually:
    + cd /media/cdrom
    + sudo sh VBoxLinuxAdditions.run
  8. +
  9. This should install the guest additions.
  10. +
+

Set up network adapters on guest VM

+

The network interfaces should already be configured on the guest within + the virtualbox configuration.  This is available by clicking on the + VM in the virtualbox manager and selecting "Settings".  These are the + configuration settings used:

+ Adapter 1:
+   Attached to: Host-only Adapter
+   Name: vboxnet0 
+

Adapter 2:
+   Attached to: Nat Network
+   Name: NatNetwork

+

On the guest VM itself, the network settings are specified in a file + called /etc/network/interfaces.  Here are the current contents of + that file:

+
source /etc/network/interfaces.d/*

auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
  address 10.28.42.20
  netmask 255.255.255.0
  network 10.28.42.0
  broadcast 10.28.42.255
  dns-domain cakelampvm.com
  dns-search cakelampvm.com
  dns-nameservers 127.0.0.1 8.8.8.8
+
auto enp0s8
+
iface enp0s8 inet dhcp
+

+

Handy Techniques

+

Get the network address on the guest vm

+

Run this command: ifconfig

+

In the results, look for "inet addr".  There may be more than one, + if there are multiple network interfaces.

+

How to cleanly reboot or shut down the guest VM

+

When you've got the DNS and everything integrated, these commands will + manage the vm's state:

+

First, log into the guest VM: ssh developer@cakelampvm.com

+

Then, reboot the guest VM: sudo reboot

+

Or, halt the guest VM: sudo shutdown -h now

+

Using these commands is better than just cycling the power from the + virtualbox control panel.

+

Notes on building the Cake Lamp VM

+

This is all work that should already have been done.  It is + mentioned here just as breadcrumbs for a future vm builder.

+ +


+

+ + diff --git a/production/sites/cakelampvm.com/docs/manual/images/host_only_adapter_dhcp_server.png b/production/sites/cakelampvm.com/docs/manual/images/host_only_adapter_dhcp_server.png new file mode 100644 index 00000000..53db9561 Binary files /dev/null and b/production/sites/cakelampvm.com/docs/manual/images/host_only_adapter_dhcp_server.png differ diff --git a/production/sites/cakelampvm.com/docs/manual/images/host_only_network_adapter.png b/production/sites/cakelampvm.com/docs/manual/images/host_only_network_adapter.png new file mode 100644 index 00000000..dd87e5fe Binary files /dev/null and b/production/sites/cakelampvm.com/docs/manual/images/host_only_network_adapter.png differ diff --git a/production/sites/cakelampvm.com/docs/manual/images/nat_network_config.png b/production/sites/cakelampvm.com/docs/manual/images/nat_network_config.png new file mode 100644 index 00000000..3299a3bd Binary files /dev/null and b/production/sites/cakelampvm.com/docs/manual/images/nat_network_config.png differ diff --git a/production/sites/cakelampvm.com/images/green-check-mark-in-circle-hi.png b/production/sites/cakelampvm.com/images/green-check-mark-in-circle-hi.png new file mode 100644 index 00000000..ab1d67bf Binary files /dev/null and b/production/sites/cakelampvm.com/images/green-check-mark-in-circle-hi.png differ diff --git a/production/sites/cakelampvm.com/images/green_globe_exclamation_point_570.jpg b/production/sites/cakelampvm.com/images/green_globe_exclamation_point_570.jpg new file mode 100644 index 00000000..8cb9aa73 Binary files /dev/null and b/production/sites/cakelampvm.com/images/green_globe_exclamation_point_570.jpg differ diff --git a/production/sites/cakelampvm.com/images/red_exclamation_mark_icon_256.png b/production/sites/cakelampvm.com/images/red_exclamation_mark_icon_256.png new file mode 100644 index 00000000..bae1cf6c Binary files /dev/null and b/production/sites/cakelampvm.com/images/red_exclamation_mark_icon_256.png differ diff --git a/production/sites/cakelampvm.com/images/red_x_1194985626525719339tasto_11_architetto_fran_01.svg.med.png b/production/sites/cakelampvm.com/images/red_x_1194985626525719339tasto_11_architetto_fran_01.svg.med.png new file mode 100644 index 00000000..c6d020ed Binary files /dev/null and b/production/sites/cakelampvm.com/images/red_x_1194985626525719339tasto_11_architetto_fran_01.svg.med.png differ diff --git a/production/sites/cakelampvm.com/index.html b/production/sites/cakelampvm.com/index.html new file mode 100644 index 00000000..66fc8d61 --- /dev/null +++ b/production/sites/cakelampvm.com/index.html @@ -0,0 +1,25 @@ + + + + + cakelampvm.com official internet site (NOT the local virtual machine) + + +
uh oh red exclamation + x marks a bad spot + uh oh red exclamation
+

cakelampvm.com REAL INTERNET site

+

+

★★ If you are running the cakelampvm, ★★
+ ★★ then it is not yet configured properly. ★★

+

This is the cakelampvm.com domain that is + actually on the internet.

+

Official cakelampvm setup guide: The + cakelampvm.com VM: Configuration and Usage

+
uh oh red exclamation + x marks a bad spot + uh oh red exclamation +
+ + diff --git a/production/sites/cakelampvm.com/vm_index.html b/production/sites/cakelampvm.com/vm_index.html new file mode 100644 index 00000000..362b3215 --- /dev/null +++ b/production/sites/cakelampvm.com/vm_index.html @@ -0,0 +1,34 @@ + + + + + cakelampvm.com served by your local virtual machine! + + +
yay, green exclaimed you're in the right place, and dns is being hosted by your local cakelampvm.com virtual machine + yay, green exclaimed
+

Yes!
+ You're on the cakelampvm.com virtualized site!

+

+

★★ Your cakelampvm virtual machine seems + to be ★★
+ ★★  successfully overriding this domain (and any  ★★
+ ★★ other sites you have added to host on the vm). ★★

+

This is the cakelampvm.com domain that is + served from your cakelampvm virtual machine
+ (as long as browser URL bar actually + says just "http://cakelampvm.com" or "http://www.cakelampvm.com").

+

Official cakelampvm setup guide: The cakelampvm.com VM: + Configuration and Usage

+
yay, green exclaimed you're in the right place, and dns is being hosted by your local cakelampvm.com virtual machine + yay, green exclaimed +
+ + diff --git a/scripts/core/functions.sh b/scripts/core/functions.sh index 67977085..c078c90a 100644 --- a/scripts/core/functions.sh +++ b/scripts/core/functions.sh @@ -49,6 +49,8 @@ if [ -z "$skip_all" ]; then return $? } + ############## + # displays the value of a variable in bash friendly format. function var() { HOLDIFS="$IFS" @@ -84,6 +86,8 @@ if [ -z "$skip_all" ]; then IFS="$HOLDIFS" } + ############## + # when passed a list of things, this will return the unique items from that list as an echo. function uniquify() { @@ -104,6 +108,8 @@ if [ -z "$skip_all" ]; then fi } + ############## + function success_sound() { if [ ! -z "$CLAM_FINISH_SOUND" ]; then @@ -118,6 +124,20 @@ if [ -z "$skip_all" ]; then fi } + ############## + + # echoes the maximum number of columns that the terminal supports. usually + # anything you print to the terminal with length less than (but not equal to) + # maxcols will never wrap. + function get_maxcols() + { + # calculate the number of columsn in the terminal. + local cols=$(stty size | awk '{print $2}') + echo $cols + } + + ############## + # checks the result of the last command that was run, and if that failed, # then this complains and exits from bash. the function parameters are # used as the message to print as a complaint. @@ -139,19 +159,28 @@ if [ -z "$skip_all" ]; then fi } + ############## + # wraps secure shell with some parameters we like, most importantly to enable X forwarding. function ssh() { local args=($*) - save_terminal_title # we remember the old terminal title, then force the TERM variable to a more generic # version for the other side (just 'linux'); we don't want the remote side still # thinking it's running xterm. + save_terminal_title + # we save the value of TERM; we don't want to leave the user's terminal + # brain dead once we come back from this function. + local oldterm="$TERM" export TERM=linux /usr/bin/ssh -X -C "${args[@]}" restore_terminal_title + # restore the terminal variable also. + TERM="$oldterm" } + ############## + # locates a process given a search pattern to match in the process list. # supports a single command line flag style parameter of "-u USERNAME"; # if the -u flag is found, a username is expected afterwards, and only the @@ -267,6 +296,9 @@ if [ -z "$skip_all" ]; then fi } + ############## + +#hmmm: holy crowbars, this is an old one. do we ever still have any need of it? # an unfortunately similarly named function to the above 'ps' as in process # methods, but this 'ps' stands for postscript. this takes a postscript file # and converts it into pcl3 printer language and then ships it to the printer. @@ -280,9 +312,21 @@ if [ -z "$skip_all" ]; then done } -# function fix_alsa() { -# sudo /etc/init.d/alsasound restart -# } +#hmmm: not really doing anything yet; ubuntu seems to have changed from pulseaudio in 17.04? + # restarts the sound driver. + function fix_sound_driver() { + # stop bash complaining about blank function body. + local nothing= +#if alsa something +# sudo service alsasound restart +#elif pulse something +# sudo pulseaudio -k +# sudo pulseaudio -D +#else +# something else...? +#fi + + } function screen() { save_terminal_title diff --git a/scripts/core/inventory.sh b/scripts/core/inventory.sh index eeb77039..db33f74c 100644 --- a/scripts/core/inventory.sh +++ b/scripts/core/inventory.sh @@ -38,7 +38,7 @@ fi # decide whether they've got splitter available or not. if [ -f "$FEISTY_MEOW_BINARIES/splitter" -o -f "$FEISTY_MEOW_BINARIES/splitter.exe" ]; then # calculate the number of columsn in the terminal. - cols=$(stty size | awk '{print $2}') + cols=$(get_maxcols) splitter="$FEISTY_MEOW_BINARIES/splitter --maxcol $(($cols - 1))" else # not available, so just emit as huge overly long string. diff --git a/scripts/files/remove_here_if_not_there.sh b/scripts/files/remove_here_if_not_there.sh index ba0d8dff..403a0f7c 100644 --- a/scripts/files/remove_here_if_not_there.sh +++ b/scripts/files/remove_here_if_not_there.sh @@ -4,9 +4,8 @@ function print_instructions() { echo -e "\n$(basename $0 .sh):\n" -#hmmm: extract to a terminal size function. -# calculate the number of columsn in the terminal. -cols=$(stty size | awk '{print $2}') + # calculate the number of columsn in the terminal. + local cols=$(get_maxcols) echo -e 'this script takes two parameters, a "here" folder and a "there" folder, almost as if it were a copy command. but instead, this removes any file from under the "here" location if it cannot be found in the "there" location. so the "there" location is considered a more definitive template of what should be in "here", such that we strip out what "there" does not have.\n\n the most" useful way to use this script is for a "here" hierarchy that is a copy of an older version of another "there" hierarchy. the "there" hierarchy may have changed a lot, including new files, changed files, and deleted files. it is a simple operation to copy everything from "there" into "here" (such as by using the command [ cp -R "$there"/* "$here" ] ) , but it is a lot harder to determine what stuff in "here" is out of date and should be removed. that is where this script comes in; it can be run to flush out any older things in "here", rather than requiring the user to manually find all those files. ' | splitter --maxcol $(($cols - 1)) diff --git a/scripts/rev_control/version_control.sh b/scripts/rev_control/version_control.sh index 08a9a07c..5c343b5d 100644 --- a/scripts/rev_control/version_control.sh +++ b/scripts/rev_control/version_control.sh @@ -17,10 +17,8 @@ export MAX_DEPTH=5 # use our splitter tool for lengthy output if it's available. if [ ! -z "$(which splitter)" ]; then TO_SPLITTER="$(which splitter)" - -#hmmm: another reusable chunk here, getting terminal size. # calculate the number of columsn in the terminal. - cols=$(stty size | awk '{print $2}') + cols=$(get_maxcols) TO_SPLITTER+=" --maxcol $(($cols - 1))" else TO_SPLITTER=cat @@ -290,6 +288,18 @@ function check_branch_state() return $to_return } +# only shows the branch state if it's not okay. +# note that this is not the same as a conditional branch (ha ha). +function show_branch_conditionally() +{ + local this_branch="$1"; shift + + state=$(check_branch_state "$this_branch") + if [ "$state" != "okay" ]; then + echo "=> branch '$this_branch' state is not clean: $state" + fi +} + # the git update process just gets more and more complex when you bring in # branches, so we've moved this here to avoid having a ton of code in the # other methods. @@ -307,16 +317,14 @@ function do_careful_git_update() local this_branch="$(my_branch_name)" - state=$(check_branch_state "$this_branch") - echo "=> branch '$this_branch' state prior to remote update is: $state" + show_branch_conditionally "$this_branch" # first update all our remote branches to their current state from the repos. git remote update | $TO_SPLITTER promote_pipe_return 0 test_or_die "git remote update" - state=$(check_branch_state "$this_branch") - echo "=> branch '$this_branch' state after remote update is: $state" + show_branch_conditionally "$this_branch" # this code is now doing what i have to do when i repair the repo. and it seems to be good so far. local branch_list=$(all_branch_names) @@ -327,8 +335,7 @@ function do_careful_git_update() promote_pipe_return 0 test_or_die "git switching checkout to remote branch: $bran" - state=$(check_branch_state "$bran") - echo "=> branch '$bran' state is: $state" + show_branch_conditionally "$this_branch" remote_branch_info=$(git ls-remote --heads origin $bran 2>/dev/null) if [ ! -z "$remote_branch_info" ]; then diff --git a/scripts/tty/terminal_titler.sh b/scripts/tty/terminal_titler.sh index 8bc6ccd3..36086021 100644 --- a/scripts/tty/terminal_titler.sh +++ b/scripts/tty/terminal_titler.sh @@ -4,7 +4,7 @@ source "$FEISTY_MEOW_SCRIPTS/core/functions.sh" source "$FEISTY_MEOW_SCRIPTS/core/common.alias" # uncomment this to get extra noisy debugging. -#export DEBUG_TERM_TITLE=true +export DEBUG_TERM_TITLE=true # puts a specific textual label on the terminal title bar. # this doesn't consider any previous titles; it just labels the terminal. @@ -31,28 +31,40 @@ function apply_title_to_terminal() function set_terminal_title() { apply_title_to_terminal $* + # we're enforcing a new title from here on. + unset PRIOR_TERMINAL_TITLE save_terminal_title } -# reads the current terminal title, if possible, and saves it to our record. -function save_terminal_title() +# echoes back the current title on the terminal window, if we can acquire it. +function get_terminal_title() { + local term_title_found="" # save the former terminal title if we're running in X with xterm. which xprop &>/dev/null if [ $? -eq 0 ]; then # make sure we're actually using xterm *and* that we have a window ID. if [[ "$TERM" =~ .*"xterm".* && ! -z "$WINDOWID" ]]; then - local prior_title="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')" - if [ ! -z "$prior_title" ]; then - if [ ! -z "$DEBUG_TERM_TITLE" ]; then - echo "saving prior terminal title as '$prior_title'" - fi - export PRIOR_TERMINAL_TITLE="$prior_title" - else - if [ ! -z "$DEBUG_TERM_TITLE" ]; then - echo "not saving prior terminal title which was empty" - fi - fi + term_title_found="$(xprop -id $WINDOWID | perl -nle 'print $1 if /^WM_NAME.+= \"(.*)\"$/')" + fi + fi + echo "$term_title_found" +} + +# reads the current terminal title, if possible, and saves it to our record. +function save_terminal_title() +{ + local title="$(get_terminal_title)" + if [ ! -z "$title" ]; then + # there was a title, so save it. + if [ ! -z "$DEBUG_TERM_TITLE" ]; then + echo "saving prior terminal title as '$prior_title'" + fi + export PRIOR_TERMINAL_TITLE="$prior_title" + else + # the terminal had no title, or we couldn't access it, or there's no terminal. + if [ ! -z "$DEBUG_TERM_TITLE" ]; then + echo "not saving prior terminal title which was empty" fi fi }