d1d28aaa8ba161819c89b161f0aad7d0e396f404
[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 if [ ! -d "$TMP" ]; then
18   mkdir -p $TMP
19   chown $USER $TMP
20   if [ $? -ne 0 ]; then
21     echo "failed to chown $TMP to user's ownership."
22   fi
23   log_feisty_meow_event "created transient area \"$TMP\" for $USER on $(date_stringer)." 
24 fi
25
26 # set other temporary variables to the same place as TMP.
27 export TEMP=$TMP
28
29 # Make sure no one else is playing around in the temporary directory.
30 chmod 700 $TMP
31
32 if [ ! -z "$DEBUG_FEISTY_MEOW" ]; then echo done creating temporary directory....; fi
33