Commit be5b940c authored by Vitaly Lipatov's avatar Vitaly Lipatov

create_sep_sites.sh: last fixes

parent 53744eae
......@@ -9,6 +9,7 @@ ALIASLIST=
. ./config
. ./functions
. ./functions-apache
set_vars
......
......@@ -12,29 +12,37 @@ for URL in $(cat create_sep_sites.list | grep -v "#") ; do
NAME=$(basename $URL)
[ -L "$MAINSITEDIR/$NAME" ] && { echo "Skipping $NAME" ; continue ; }
echo
echo "Copying $NAME..."
du -s -h $MAINSITEDIR/$NAME
echo "Creating conf for $NAME..."
#du -s -h $MAINSITEDIR/$NAME
SEPUSER=${MAINNAME}_$NAME
userdel -r $SEPUSER
id $SEPUSE >/dev/null || fatal "$SEPUSER already exists"
# if need overwrite all
#userdel -r $SEPUSER
#id $SEPUSER >/dev/null || fatal "$SEPUSER already exists"
# Переименовываем, если это основной пользователь
if id $SEPUSER >/dev/null ; then
if getent passwd $SEPUSER | grep -q /home/azbyka/ ; then
usermod -l ${SEPUSER/azbyka_/} $SEPUSER || fatal
groupmod -n ${SEPUSER/azbyka_/} $SEPUSER || fatal
else
echo "$SEPUSER already exists, skipping"
continue
fi
fi
test -d /home/$SEPUSER && fatal "$SEPUSER already created"
cat <<EOF
======== $SEPUSER ============
EOF
./add_user.sh $SEPUSER || fatal
./add_site.sh $SEPUSER $SEPUSER NORESTARTAPACHE
./add_user.sh $SEPUSER 2>>$0.errlog || fatal
./add_site.sh $SEPUSER $SEPUSER NORESTARTAPACHE 2>>$0.errlog
cat <<EOF
Abs path: /home/$SEPUSER/www/$SEPUSER/$NAME/
Real URL: http://$MAINDOMAIN/$NAME
EOF
subst "s|prepend.php|prepend-azbyka.php|g" /etc/httpd2/conf/sites-enabled/$SEPUSER.conf
TARGET="/home/$SEPUSER/www/$SEPUSER/"
rsync -av $MAINSITEDIR/$NAME/ $TARGET/$NAME/
chown $SEPUSER -R $TARGET/$NAME/
break
done
service httpd2 reload
#!/bin/bash
. ./config
fatal()
{
echo "$@" >&2
exit 1
}
for URL in $(cat create_sep_sites.list | grep -v "#") ; do
NAME=$(basename $URL)
[ -L "$MAINSITEDIR/$NAME" ] && { echo "Skipping $NAME" ; continue ; }
echo
echo "Copying $NAME..."
SEPUSER=${MAINNAME}_$NAME
TARGET="/home/$SEPUSER/www/$SEPUSER/"
# TODO: use rename
rsync -av $MAINSITEDIR/$NAME/ $TARGET/$NAME/
chown $SEPUSER -R $TARGET/$NAME/
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment