aboutsummaryrefslogtreecommitdiff
path: root/tools/boca-fixssh
blob: 574de7c155d7d615a024e79d60f07cb965567bab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash

if [ "`id -u`" != "0" ]; then
    echo "Must be run as root"
    exit 1
fi

chown root.root /var/log/boca-fixssh.* 2>/dev/null
chmod 600 /var/log/boca-fixssh.* 2>/dev/null

if [ "`id bocassh 2>/dev/null`" != "" ]; then
    wwwboca=/var/www/boca
    casa=$wwwboca/home
    if [ ! -d $casa/.ssh ]; then
	mkdir -p $casa/.ssh
	chown -R bocassh.bocassh $casa 2>/dev/null
	chmod 700 $casa
	chmod 700 $casa/.ssh
	usermod -d $casa bocassh
    fi
    for i in 1 2 3 4 5 6; do
	touch $casa/.ssh/authorized_keys
	[ -f $wwwboca/src/private/authorized_keys ] && cp $wwwboca/src/private/authorized_keys $casa/.ssh/authorized_keys
	chmod 600 $casa/.ssh/authorized_keys
	[ "$i" == "6" ] || sleep 10
    done
fi