#!/bin/sh

# bsam-start
# Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011, 2012,
# 2017, 2019, 2020, 2023 Joseph Rosevear

# This file is part of an application of SAM for GNU/Linux Slackware
# known as SAM-GLS.

# SAM-GLS 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; either version 3 of the License, or (at
# your option) any later version.

# SAM-GLS 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 <http://www.gnu.org/licenses/>.

# (Slackware is a registered trademark of Patrick Volkerding and
# Slackware Linux, Inc.)



# Joseph Rosevear 120813 I rewrote this and made it a simple invocation of a
# new script called bstart.

# Joseph Rosevear 170128 I changed the line below to point to
# /mnt/150605aa2/bstart instead of ~/bstart

# Joseph Rosevear 170128 I added a lines to run brc and source bprofile.  I
# made brc from the original /etc/rc.d/rc.SAM and bprofile from the original
# /opt/SAM/tips/bash_profile.  I edited them.  I'm doing this to prepare
# sam_temp_base and scratch and to get suitable defintions of sam_temp_base
# and perhaps some other variables and perhaps some other preparations.

# Joseph Rosevear 171215 I changed this script to know where it lives
# (place=`dirname $0`).  Then I used $place in the invocations of brc,
# bprofile, and bstart.

# Joseph Rosevear 180330 I reversed the order of invocations of
# bprofile and brc.  I did that because I also changed brc, and now it
# needs bprofile to run first.

# Joseph Rosevear 191103 I changed the invocation of bstart:

# Was:

#    $place/bstart "love; exhand; export sam_bye_command=exit; $*"

# Now:

#    $place/bstart "love; exhand; sam_bye_command=exit; $*"

# Joseph Rosevear 200826 I made this from script begin by copying it.

# Joseph Rosevear 200826 I removed "exhand;" from the invocation of
# bstart.

# Joseph Rosevear 230513 I used $sam_root instead of $place below the
# sourcing of bprofile, as it defines sam_root.

# I added exported definitions of init and lib for when they don't
# exist.

# I changed the comments and added exported definitions for init and
# lib when they are "".


# Joseph Rosevear 230601 I commented-out the exported definition of
# sam_distro.



# Definitions
export sam_root=`dirname $0`

if [ "$init" = "" ]; then

   export init=$sam_root/init
fi

if [ "$lib" = "" ]; then

   export lib=$sam_root/lib
fi

export sam_mark_num=1
export env_scratch=$sam_temp_base/scratch
export sam_set_version=2
export sam_temp_base=/tmp/`whoami`
# export sam_distro=$sam_root/lib

if [ "$bprofile" != "" ]; then

   . $bprofile
fi

# Beginning of main program.
echo "in $BASH_SOURCE"

mkdir --parents $sam_temp_base/scratch
umask `cat $HOME/.SAM.umask`


$sam_root/go/sam1 24 `${init}` "; $*"
