6dbd31c3415ea797a493d58e92004d57b60ff8c0
[feisty_meow.git] / scripts / core / create_tempdir.sh
1 #!/bin/bash
2
3 # create_tempdir:
4 #
5 # This creates a temporary directory for transient files if such a directory
6 # does not already exist.
7
8 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo creating temporary directory...; fi
9
10 if [ -z "$TMP" ]; then
11   # main declaration of the transients area.
12   export TMP=$HOME/.tmp
13 fi
14
15 source "$FEISTY_MEOW_SCRIPTS/core/functions.sh"
16
17 LOG_FILE=$TMP/zz_transients.log
18   # log file for this script.
19
20 word=Verified
21 if [ ! -d "$TMP" ]; then
22   mkdir -p $TMP
23   word=Created
24   chown $USER $TMP
25   if [ $? -ne 0 ]; then
26     echo "failed to chown $TMP to user's ownership."
27   fi
28 fi
29 echo "$word transient area \"$TMP\" for $USER on $(date_stringer)." >>$LOG_FILE
30
31 # set other temporary variables to the same place as TMP.
32 export TEMP=$TMP
33
34 # Make sure no one else is playing around in the temporary directory.
35 chmod 700 $TMP
36
37 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo done creating temporary directory....; fi
38