Change home dir var, fix var name permission
[autosshd_ALT.git] / autosshd / share / autossh-conf
blob60054aa6ec32f44f96d630e5d25d05260cc70f24
1 #!/bin/sh
2 # autosshd-conf shell for autosshd that export variables from root to _anyssh user
5 init_autossh(){
6 # Source function library.
7 . /etc/init.d/functions
9 # AutoSSHDaemon configuration
10 SYSCONFIGFILE="/etc/sysconfig/autosshd"
11 SourceIfNotEmpty $SYSCONFIGFILE
12 AUTOSSH_PIDFILE=${PIDFILEDIR}/$(basename $1 .conf).pid
13 AUTOSSH_LOCKFILE=${LOCKFILEDIR}/$(basename $1 .conf).lck
14 [ -z "$AUTOSSH_LOGFILE" ] && AUTOSSH_LOGFILE=/var/lib/autosshd/$(basename $1 .conf).log
15 export AUTOSSH_LOGFILE AUTOSSH_LOCKFILE AUTOSSH_PIDFILE AUTOSSH_LOGLEVEL AUTOSSH_POLL AUTOSSH_GATETIME AUTOSSH_DEBUG
17 VERBOSE=false
20 check_permissions(){
21 AUTOSSH_FILES="$AUTOSSH_LOGFILE" # "$AUTOSSH_LOCKFILE $AUTOSSH_PIDFILE"
22 for var in $AUTOSSH_FILES ; do
23 if [ -w "$var" ] || [ ! -e "$var" ]; then
24 is_ok $var
25 else
26 echo "Remove $var file"
27 #sudo rm -f $var
29 done
31 DSAFILES="/$HOME/.ssh/id_dsa*"
32 if ls $DSAFILES &> /dev/null ; then
33 is_ok $DSAFILES
34 else
35 echo "No dsa files in $(realpath $DSAFILES)"
38 for i in $DSAFILES ; do
39 file_permission="$(stat -c "%a" $i)"
40 if [ "$file_permission" == "600" ] || [ "$file_permission" == "400" ]; then
41 is_ok $i
42 else
43 echo "Permissions $file_permission for $i are too open."
45 done
48 is_ok(){
49 $VERBOSE && echo "File $1 permission is ok"
52 run_autossh(){
53 autossh $@
56 #Fix for import init function
57 if [ -n "$1" ] ; then
58 init_autossh $1
59 check_permissions
60 shift
61 run_autossh $@