2011-07-25

useful bash shell

useful bash shell with colors to hint at importance
  • user@host
    (helpful when logged to several hosts simultaneously)
  • PWD above prompt
    (so as not to make the prompt appear at a variable column)
  • 24 hour time and date
    (helpful to know when you last used the shell, rough timer of statements)
  • History and jobs
    (a bit more context, shaded to denote less importance)
  • sectioned with '[' and ']' characters


On a Unix command line, input the following:

$ cat <<HEREDOC1

# .bashrc
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# User specific aliases and functions

# set a useful login prompt
PS1="\n\[\033[1;37m\][\u@\h:\w]\[\033[0m\] \[\033[1;35m\][\t on \d]\[\033[0m\] [history \!] [jobs \j]\n\[\033[1;37m\]$\[\033[0m\] "

# Add other directorys

PATH="${PATH}:${HOME}/bin"
export PATH

my_nano="$(which nano)"

my_clear="$(which clear)"
my_ps="$(which ps)"
my_ls="$(which ls)"
my_rm="$(which rm)"

alias l="${my_ls} -laspF"

alias lr="${my_ls} -lasFR"
alias lt="${my_ls} -lastF"
alias cls="${my_clear}"
alias clr="${my_clear}"
alias delete="${my_rm} --verbose --recursive --preserve-root --force"
alias psA="${my_ps} -aAdeflc"
alias psa="${my_ps} -ef"
alias e="${my_nano}"
HEREDOC1 > ~/.bashrc

$ cat <<HEREDOC2. .bashrc
HEREDOC2 > ~/.bash_profile

using putty, logged to an Amazon EC2 instance

2010-05-23

In two paragraphs, an interesting description of the moral purpose of Libertarian (old Liberal) politics. 
From the essay Liberty, Dignity, and Responsibility: The Moral Triad of a Good Society by Daniel B. Klein
The Interdependence of Dignity and Liberty
If the individual consists of multiple selves, the question arises: Should the government protect  Dr. Jekyll from Mr. Hyde, just as it protects the innocent citizen from the criminal? If the individual is multiple, then in a way his actions are not so personal after all. One self imposes an externality on other selves, and externalities raise the issue of whether the government ought to intervene. Americans commonly make the assumption that intervention is called for with regard to opium use, gambling, Social Security, safety issues, suicide, and many other matters. But the support for paternalism rests not only on the notion of the multiple self, but on the presumption that the conflict among the selves represents a sort of moral collapse. It is rather analogous to butting into a domestic dispute. A married couple needs to learn how to respect and tolerate one another, their dispute belonging to the drama of their marriage. In the case of the multiple self, the paternalist solution can make sense only once the hope for self-respect is lost. The paternalist presumes that the crew has taken over the ship, that all respect for the captain is lost and the crew no longer responsive to him. Dignity is gone. It is time, reasons the paternalist, to sacrifice liberty, too.

Thus, low societal dignity leads to coercion.  The less the citizen preserves his own dignity, the less it makes sense to say that he acts in keeping with the captain’s mission. Such doubt about individuals’ mastery over their own behavior is manifest in the war on smoking waged by U.S. Commissioner of Food and Drugs David Kessler. He views the decision to smoke as resting in the hands of tobacco companies. Owing to their practices, he says, “Most smokers are in effect deprived of the choice to stop smoking.” Part of the reason Kessler is prepared to doubt the dignity of the people is that, in fact, their dignity is not as high as it might be. For example, John Gravett (1993) wrote a magazine column titled “Life-Long Smokers Should Welcome Hillary’s ‘Nico-Tax.’” Gravett declares that the First Lady’s tax hike of two dollars per pack “will surely bolster my resolve to quit.”  “I, like so many other life-long smokers, am only waiting for a good enough reason to quit once and for all”. Rather than searching as an adult to come to terms with his habit, Gravett glibly asks that he (and all other smokers) be treated as a helpless child. Citizens such as Gravett lend truth and legitimacy to Kessler’s presumptions.

A short thought.
  • The use of the multiple-selves psychological paradigm is for the purpose of explaining the indignity of government parenting.  Refutations should not focus on this. 
  • This quote is a very good explanation of the indignity of government parenting that is easy to understand and read.

2010-01-11

abyss webserver (abyssws) -- RH Linux integration

abyss webserver by Aprelium
A nice commercial web server. 
The only free (as in money) web server that has great user and group account control (when I searched about 2 years ago).
Stable, simple, seems to work well.

Here are the pre-setup steps for integrating this into a Red Hat-type Linux setup (I'm using CentOS 5.1)
if you want a safe read-only http-based file server with user and group password permissions.


Specifically,
  • integrate with init.d service interface (the command line script service, common to Red Hat distro's)
  • use new isolated user for abyss process security
Shell Steps
    1. # unloading package
      cd /tmp

      wget http://www.aprelium.com/data/abwsx1.tgz


      tar -xvcf abwsx1.tgz


      mkdir /var/www-abyssws


      mv abyssws /var/www-abyssws

    2. # system interaction
      useradd -c "a user for the abyssws webserver" -d /var/www-abyssws/ -M -r -s /sbin/nologin user_abyssws

      chown -R user_abyssws /var/www-abyssws/
    3. # service interaction
      echo '\# if you need to start other stuff before abyss, then do that here
      sudo -u user_abyssws /var/www-abyssws/abyssws &' > /root/bin/abyss-start.sh

      chmod 755 /root/bin/abyss-start.sh


      touch /etc/init.d/rc.d/abyssws

      # copy the following grayed text to the just touched file /etc/init.d/rc.d/abyssws
      #!/bin/sh
      #
      # abyssws
      #
      # chkconfig: - 85 15
      # description: abyss ws
      #
      # processname: abyssws

      ### BEGIN INIT INFO
      # Provides: abyssws
      # Required-Start: $local_fs $network
      # Required-Stop: $local_fs $network
      # Short-Description: start and stop abyss web server
      ### END INIT INFO

      # Source function library
      . /etc/rc.d/init.d/functions

      progname=abyssws
      abysswsprog="/var/www-abyssws/abyssws"
      abysswsstart="/root/bin/abyss-start.sh"
      RETVAL=0

      start() {
      echo -n $"Starting $progname: "
      $abysswsstart
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$progname
      return $RETVAL
      }

      stop() {
      echo -n $"Stopping $progname: "
      $abysswsprog --stop
      RETVAL=$?
      echo
      [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$progname
      return $RETVAL
      }

      reload() {
      echo -n $"Reloading $progname: "
      $abysswsprog --restart
      RETVAL=$?
      echo
      return $RETVAL
      }

      case "$1" in
      start)
      start
      ;;
      stop)
      stop
      ;;
      restart)
      stop
      start
      ;;
      condrestart)
      if [ -f /var/lock/subsys/$progname ]; then
      stop
      start
      fi
      ;;
      reload)
      reload
      ;;
      status)
      status $progname
      RETVAL=$?
      ;;
      *)
      echo $"Usage: $0 {start|stop|restart|condrestart|reload|status}"
      RETVAL=1
      esac

      exit $RETVAL
    4. ln -s /etc/rc.d/init.d/abyssws /etc/rc0.d/K15abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc1.d/K15abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc2.d/K15abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc3.d/S85abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc4.d/K15abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc5.d/S85abyssws
      ln -s /etc/rc.d/init.d/abyssws /etc/rc6.d/K15abyssws
       
    Now you're done with the Linux integration.

    Other things to do:
    1. # this many not work, since no file /var/www-abyssws/abyss.conf exists
      start-abyss.sh
    2. with a browser go to
         http://hostname:9999
      complete the web-based setup
    3. # now you can use the service interface
      service abyssws restart

    Other things to consider:
    • Directories for access with abyssws should have read and execute priviledge for user user_abyss
      For me, this means adding user_abyss to my web_friends group.
      This means using the command
       chmod g+rx $directory_for_abyss
    • This exact sequence of instructions was not tested. You get the idea.