Merge branch 'dev' of feistymeow.org:feisty_meow into dev
authorChris Koeritz <fred@gruntose.com>
Sun, 7 Jan 2018 20:16:15 +0000 (20:16 +0000)
committerChris Koeritz <fred@gruntose.com>
Sun, 7 Jan 2018 20:16:15 +0000 (20:16 +0000)
production/sites/cakelampvm.com/docs/manual/cakelampvm_guide_v002.html
scripts/core/common.alias
scripts/core/functions.sh
scripts/rev_control/git_scruncher.sh [new file with mode: 0644]
scripts/rev_control/version_control.sh
scripts/site_avenger/powerup.sh
scripts/site_avenger/revamp_cakelampvm.sh
scripts/site_avenger/shared_site_mgr.sh
scripts/site_avenger/standup.sh
scripts/system/add_swap_mount.sh
scripts/wine/wine_link_maker.sh [new file with mode: 0644]

index 33de228268bc37fc50b355bba5f6768050d2f3f8..81ba2ece90304bef8c6a0e51b1e9db95460da0c8 100644 (file)
@@ -11,7 +11,7 @@
         Koeritz</span><span style="font-family: Comic Sans MS;"></span><span style="font-family: Comic Sans MS;"></span><br>
       <span style="font-family: Comic Sans MS;">feisty meow® concerns ltd</span>.</div>
     <h3 style="   text-align: center;"> Vintage: cakelampvm v002 &nbsp;&nbsp;
-      Updated: 2017-12-19 (rev. h)</h3>
+      Updated: 2018-1-7 (rev. i)</h3>
     <p>The cakelampvm project provides a Virtualbox VM that acts as an "internet
       in a bottle", serving up your web sites securely and only to your local
       host.&nbsp; The virtual machine provides DNS services (<a target="_blank"
@@ -197,6 +197,10 @@ revamp_cakelampvm</span></pre>
         <pre><span style="font-weight: bold;">passwd</span></pre>
         The 'passwd' command will ask for your current password, and then for a
         new password plus a verification of that new password.<br>
+        You will probably want to change your samba password as well, which is
+        used when accessing the virtual machine over the network.&nbsp; This is
+        a different, but very similar, command on Linux:<br>
+        <pre><span style="font-weight: bold;">smbpasswd</span></pre>
         &nbsp;</li>
       <li>Change your git configuration for the user and email address.&nbsp;
         This is how we've configured it so far:<br>
@@ -279,7 +283,7 @@ href="http://mapsdemo.cakelampvm.com">http://mapsdemo.cakelampvm.com</a></pre>
     <h4>Setting up DNS on Windows<a id="#windoze-dns" name="#windoze-dns"></a></h4>
     <p>The ipconfig tool will provide helpful information about your current
       networking and DNS configuration:</p>
-    <pre>&gt; ipconfig /all</pre>
+    <pre><span style="font-weight: bold;">&gt; ipconfig /all</span></pre>
     <p>The DNS configuration on Windows is somewhat byzantine.&nbsp; The pipe
       characters ('|') below are used to separate the menus or tabs or dialogs
       to traverse.&nbsp; Follow this path to get to the DNS config:</p>
@@ -297,7 +301,7 @@ href="http://mapsdemo.cakelampvm.com">http://mapsdemo.cakelampvm.com</a></pre>
       settings on your Host PC are right, then you may need to flush your DNS
       cache, and that might be sufficient to start getting the right IP
       address.&nbsp; On Windows, the command for flushing DNS is:</p>
-    <pre>&gt; ipconfig /flushdns</pre>
+    <pre><span style="font-weight: bold;">&gt; ipconfig /flushdns</span></pre>
     <p>and on Linux the flush DNS command can be many different things, but try
       these two most common options:</p>
     <pre><span style="font-weight: bold;"># restarts the client side DNS cache.<br>sudo service dns-clean restart</span></pre>
index 3c4a3fb237082e31634a00a00684f9483e42ca6d..9eda778841f4967b1c465899cd98d64926418296 100644 (file)
@@ -108,6 +108,7 @@ define_yeti_alias add_domain="sudo bash \$FEISTY_MEOW_SCRIPTS/system/add_domain.
 define_yeti_alias remove_domain="sudo bash \$FEISTY_MEOW_SCRIPTS/system/remove_domain.sh"
 define_yeti_alias add_apache_site="sudo bash \$FEISTY_MEOW_SCRIPTS/system/add_apache_site.sh"
 define_yeti_alias remove_apache_site="sudo bash \$FEISTY_MEOW_SCRIPTS/system/remove_apache_site.sh"
+define_yeti_alias add_swap_mount="sudo bash \$FEISTY_MEOW_SCRIPTS/system/add_swap_mount.sh"
 
 #hmmm: some magma intrusions from the fred customizations...
 define_yeti_alias revamp_cakelampvm="sudo bash \"$FEISTY_MEOW_SCRIPTS/site_avenger/revamp_cakelampvm.sh\""
index c60c94319e4e24d126e700465c66e9ece8edcecd..dc01d786208a4b7e952e5252254fa4c1d2438cf2 100644 (file)
@@ -144,7 +144,7 @@ if [ -z "$skip_all" ]; then
   function test_or_die()
   {
     if [ $? -ne 0 ]; then
-      echo -e "\n\naction failed: $*\n\nExiting script..."
+      echo -e "\n\naction failed: $*\n\n*** Exiting script..."
       error_sound
       exit 1
     fi
@@ -154,7 +154,7 @@ if [ -z "$skip_all" ]; then
   function test_or_continue()
   {
     if [ $? -ne 0 ]; then
-      echo -e "\n\nerror occurred: $*\n\nContinuing script..."
+      echo -e "\n\nerror occurred: $*\n\n=> Continuing script..."
       error_sound
     fi
   }
diff --git a/scripts/rev_control/git_scruncher.sh b/scripts/rev_control/git_scruncher.sh
new file mode 100644 (file)
index 0000000..76ca12d
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# check for whether we see a .git folder.
+if [ ! -d ".git" ]; then
+  echo This script needs to run in the directory where a git repository lives,
+  echo but we do not see a .git directory here.
+  exit 1
+fi
+
+# makes git checkouts not be as intensive on the server.
+git config --global pack.windowMemory "100m"
+git config --global pack.SizeLimit "100m" 
+git config --global pack.threads "1"
+
+
index d74fe1bd67c43c713249809e0bcbf0a991cb4b0a..8ec547f35d5e35a992edc28e49be323f8a901990 100644 (file)
@@ -11,6 +11,20 @@ source "$FEISTY_MEOW_SCRIPTS/tty/terminal_titler.sh"
 
 ##############
 
+# check git version to see if we can use autostash.
+# this appears to be an ubuntu issue, where xenial did not provide it even though the
+# feature appeared in git 2.6 and xenial claims it has git version 2.7.4.  eventually,
+# this version test can go away.
+gitvertest="$(git version | sed -e 's/git version [0-9]\.//' | sed -e 's/\.[0-9][0-9]*$//' )"
+if (( $gitvertest >= 11 )); then
+  # auto-stash is not available until 2.6 for git, but ubuntu is misreporting or using a
+  # differing version number somehow.  we are sure autostash was missing on ubuntu xenial
+  # with git 2.7.4 and it's definitely present in zesty with git at 2.11.
+  PULL_ADDITION='--rebase --autostash'
+fi
+
+##############
+
 # the maximum depth that the recursive functions will try to go below the starting directory.
 export MAX_DEPTH=5
 
@@ -379,6 +393,8 @@ function do_careful_git_update()
   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.
+  # note that we allow the local branch to be merged with its remote counterpart; otherwise we would
+  # miss changes that happened elsewhere which should be seen in our local copy.
   local branch_list=$(all_branch_names)
   local bran
   for bran in $branch_list; do
@@ -392,7 +408,9 @@ function do_careful_git_update()
     remote_branch_info=$(git ls-remote --heads origin $bran 2>/dev/null)
     if [ ! -z "$remote_branch_info" ]; then
       # we are pretty sure the remote branch does exist.
-      git pull --no-ff origin "$bran" | $TO_SPLITTER
+      git pull $PULL_ADDITION origin "$bran" | $TO_SPLITTER
+# we may want to choose to do fast forward, to avoid crazy multiple merge histories
+# without any changes in them.  --no-ff
       promote_pipe_return 0
     fi
     test_or_die "git pull of remote branch: $bran"
@@ -404,7 +422,10 @@ function do_careful_git_update()
 
   # now pull down any changes in our own origin in the repo, to stay in synch
   # with any changes from others.
-  git pull --no-ff --all | $TO_SPLITTER
+  git pull $PULL_ADDITION --all | $TO_SPLITTER
+#is the above really important when we did this branch already in the loop?
+#it does an --all, but is that effective or different?  should we be doing that in above loop?
+# --no-ff   
   promote_pipe_return 0
   test_or_die "git pulling all upstream"
 
@@ -443,9 +464,10 @@ function do_update()
   elif [ -d ".git" ]; then
     if test_writeable ".git"; then
       $blatt
-      git pull --no-ff 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+      git pull $PULL_ADDITION 2>&1 | grep -v "X11 forwarding request failed" | $TO_SPLITTER
+#ordinary pulls should be allowed to do fast forward: --no-ff 
       promote_pipe_return 0
-      test_or_die "git pull of origin without fast forwards"
+      test_or_die "git pull of origin"
     fi
   else
     # this is not an error necessarily; we'll just pretend they planned this.
index ff2a99441a825320fc6742edd78d57bf6421439e..3709bc301958a2ed52274f7d7fe07a77ec2c04d9 100644 (file)
@@ -103,20 +103,5 @@ create_site_links "$site_store_path" "$theme_name"
 
 sep
 
-# go with the default user running the script.
-user_name=$USER
-if [ ! -z "$user_name" -a "$user_name" != "root" ]; then
-  echo "Chowning the apps folder to be owned by: $user_name"
-#hmmm: have to hope for now for standard group named after user 
-  chown -R "$user_name:$user_name" "$BASE_APPLICATION_PATH"
-  test_or_die "Chowning $BASE_APPLICATION_PATH to be owned by $user_name"
-
-else
-echo "user name failed checks for chowning, was '$user_name'"
-fi
-
-sep
-
-
 echo "Finished powering up the site in '${app_dirname}'."
 
index 2717b3a65d7a45abb1ee19fe16a436659e2884f4..e1c268b60d98d670f11fe2bfa3d708c8c2d482ff 100644 (file)
@@ -270,6 +270,55 @@ test_or_die "enabling the new cakelampvm environment config for apache"
 
 echo Successfully configured the apache2 environment variables needed for cakelampvm.
 
+##############
+
+# add in a swap mount if not already configured.
+
+sep
+
+echo "Checking existing swap partition configuration.
+"
+
+# check for existing swap.
+free | grep -q "Swap:[[:blank:]]*[1-9][0-9]"
+if [ $? -ne 0 ]; then
+  # no swap in current session, so add it.
+  echo "Enabling ramdisk swap partition...
+"
+  add_swap_mount
+  echo "
+Enabled ramdisk swap partition for current boot session."
+fi
+
+# the above just gives this session a swap partition, but we want to have
+# the vm boot with one also.
+
+# check if there is already swap mentioned in the root crontab.  we will get root's
+# crontab below since this script has to run as sudo.
+crontab -l | grep -iq add_swap_mount
+if [ $? -ne 0 ]; then
+  # no existing swap setup in crontab, so add it.
+  echo "
+Adding a boot-time ramdisk swap partition...
+"
+  # need to do it carefully, since sed won't add lines to a null file.  we thus
+  # create a temporary file to do our work in and ignore sed as a tool for this.
+  tmpfile="$(mktemp junk.XXXXXX)"
+  crontab -l 2>/dev/null >"$tmpfile"
+  echo "
+# need to explicitly set any variables we will use.
+FEISTY_MEOW_APEX=${FEISTY_MEOW_APEX}
+# add swap space to increase memory available.
+@reboot bash $FEISTY_MEOW_APEX/scripts/system/add_swap_mount.sh
+" >>"$tmpfile"
+  # now install our new version of the crontab.
+  crontab "$tmpfile"
+  rm "$tmpfile"
+
+  echo "
+Added boot-time ramdisk swap partition to crontab for root."
+fi
+
 ##############
 ##############
 
@@ -285,6 +334,9 @@ echo "
 
 
 Thanks for revamping your cakelampvm.  :-)
+
+You may want to update your current shell's feisty meow environment by typing:
+  reconfigure_feisty_meow
 "
 
 ##############
index 3f73b3a8f033a615bbad7c7d85ec436192b7f97f..94a4f792d8bef9638cfc14d506a6db48e9b355a5 100644 (file)
@@ -351,4 +351,26 @@ function update_composer_repository()
   fi
 }
 
+# fixes the ownership for a site avenger or php application.
+# this almost certainly will require sudo capability, if there are any ownership problems
+# that need to be resolved.
+function fix_appdir_ownership()
+{
+  local appsdir="$1"; shift
+  local dir="$1"; shift
+
+  local combo="$appsdir/$dir"
+
+  # go with the default user running the script.
+  user_name="$USER"
+  if [ ! -z "$user_name" -a "$user_name" != "root" ]; then
+    echo "Chowning the apps folder to be owned by: $user_name"
+#hmmm: have to hope for now for standard group named after user 
+    chown -R "$user_name:$user_name" "$combo"
+    test_or_die "Chowning $combo to be owned by $user_name"
+  else
+    echo "user name failed checks for chowning, was found as '$user_name'"
+  fi
+}
+
 
index 5adfcc63375aa07001e8e5b2818fc526a52c56bc..cd2f689056cb674cb4a075fd7fdd2a3ae6749df9 100644 (file)
@@ -89,8 +89,12 @@ sep
 #echo default repo is "$DEFAULT_REPOSITORY_ROOT" 
 
 powerup "$APPLICATION_NAME" "$REPO_NAME" "$THEME_NAME"
-# pass the real user name who should own the files.
-# "$(logname)"
+
+sep
+
+# hmmm: pass the real user name who should own the files?
+# hmmm: "$(logname)" $USER works, but logname wasn't?
+fix_appdir_ownership "$BASE_APPLICATION_PATH" "$APPLICATION_NAME" 
 
 sep
 
index 2577f44ae4f653164dbd109d4e3449d6b75c417f..608ffc5c3306cef0a4f241f934a784e4f948a7c2 100644 (file)
@@ -2,22 +2,52 @@
 
 # auto-find the scripts, since we might want to run this as sudo.
 export WORKDIR="$( \cd "$(\dirname "$0")" && /bin/pwd )"  # obtain the script's working directory.
-source "$WORKDIR/../core/launch_feisty_meow.sh"
-
-#hmmm: should be able to add a new swap drive if desired.
-
-#hmmm: why all the hard-coded paths below?
-
-/bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=2048
+export FEISTY_MEOW_APEX="$( \cd "$WORKDIR/../.." && \pwd )"
+source "$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh"
+
+if [[ $EUID != 0 ]]; then
+  echo "This script must be run as root or sudo."
+  exit 1
+fi
+
+# optional parameters: the instance number of the swap file (best as a number),
+# and the size of the swap file to add.
+SWAP_INSTANCE="$1"; shift
+SWAP_SIZE="$1"; shift
+
+if [ "$SWAP_INSTANCE" == "--help" ]; then
+  echo "\
+$(basename $0):
+This script will add a swap partition for Linux that uses hard drive space for
+swap memory.  This increases the amount of available memory on RAM constrained
+systems.  It accepts two parameters: (1) the instance of the swap file, which
+should be a small number not already used for a swap partition, and (2) the
+size of the swap file in megabytes."
+  exit 0
+fi
+
+# if the swap instance variable is already set, then we'll use it.
+# this allows multiple different swap partitions to be added.
+if [ -z "$SWAP_INSTANCE" ]; then
+  SWAP_INSTANCE=1
+fi
+
+# allow the amount of swap space to be determined from outside the script.
+# this is measured in megabytes.
+if [ -z "$SWAP_SIZE" ]; then
+  SWAP_SIZE=2048
+fi
+
+/bin/dd if=/dev/zero of=/var/swap.${SWAP_INSTANCE} bs=1M count=${SWAP_SIZE}
 test_or_die "creating swap file"
 
-/bin/chmod 600 /var/swap.1
+/bin/chmod 600 /var/swap.${SWAP_INSTANCE}
 test_or_die "setting swap file permissions"
 
-/sbin/mkswap /var/swap.1
+/sbin/mkswap /var/swap.${SWAP_INSTANCE}
 test_or_die "formatting swap file as swap partition"
 
-/sbin/swapon /var/swap.1
+/sbin/swapon /var/swap.${SWAP_INSTANCE}
 test_or_die "enabling new swap partition"
 
 free
diff --git a/scripts/wine/wine_link_maker.sh b/scripts/wine/wine_link_maker.sh
new file mode 100644 (file)
index 0000000..743964e
--- /dev/null
@@ -0,0 +1,13 @@
+
+
+# find all the directories at this height.
+find . -mindepth 1 -maxdepth 1 -type d -exec echo {} ';' >$TMP/filestolink.txt 
+# make links with all lower case and all upper case versions of the names.
+while read line; do
+  ln -s "$line" "$(echo $line | tr '[:upper:]' '[:lower:]')"
+  ln -s "$line" "$(echo $line | tr '[:lower:]' '[:upper:]')"
+done < $TMP/filestolink.txt 
+# remove dead links.
+\rm $(find . -type l ! -exec test -e {} \; -print)
+
+