2009-06-16 07:13:24 +09:00
|
|
|
#!/bin/bash
|
|
|
|
|
2010-01-30 05:33:35 +09:00
|
|
|
# live fast! die young!
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2009-08-26 07:53:24 +09:00
|
|
|
source /etc/statusnet/setup.cfg
|
2009-06-16 07:13:24 +09:00
|
|
|
|
2010-01-28 09:03:01 +09:00
|
|
|
# setup_status_net.sh mysite 'My Site' '1user' 'owner@example.com' 'Firsty McLastname'
|
2009-06-16 07:13:24 +09:00
|
|
|
|
2010-01-28 03:08:24 +09:00
|
|
|
export nickname="$1"
|
|
|
|
export sitename="$2"
|
2010-01-28 09:03:01 +09:00
|
|
|
export tags="$3"
|
|
|
|
export email="$4"
|
|
|
|
export fullname="$5"
|
2010-01-28 03:08:24 +09:00
|
|
|
|
|
|
|
# Fixme: if this is changed later we need to update profile URLs
|
|
|
|
# for the created user.
|
|
|
|
export server="$nickname.$WILDCARD"
|
|
|
|
|
|
|
|
# End-user info
|
|
|
|
export userpass=`$PWDGEN`
|
|
|
|
export roles="administrator moderator owner"
|
|
|
|
|
|
|
|
# DB info
|
2009-06-24 01:18:10 +09:00
|
|
|
export password=`$PWDGEN`
|
2009-06-16 07:13:24 +09:00
|
|
|
export database=$nickname$DBBASE
|
|
|
|
export username=$nickname$USERBASE
|
|
|
|
|
|
|
|
# Create the db
|
|
|
|
|
2009-06-18 08:30:16 +09:00
|
|
|
mysqladmin -h $DBHOST -u $ADMIN --password=$ADMINPASS create $database
|
2009-06-16 07:13:24 +09:00
|
|
|
|
2009-08-26 07:53:24 +09:00
|
|
|
for f in statusnet.sql innodb.sql sms_carrier.sql foreign_services.sql notice_source.sql; do
|
2009-06-18 08:30:16 +09:00
|
|
|
mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $database < ../db/$f;
|
2009-06-16 07:13:24 +09:00
|
|
|
done
|
|
|
|
|
2009-06-18 08:30:16 +09:00
|
|
|
mysql -h $DBHOST -u $ADMIN --password=$ADMINPASS $SITEDB << ENDOFCOMMANDS
|
2009-06-16 07:13:24 +09:00
|
|
|
|
2009-12-08 04:34:03 +09:00
|
|
|
GRANT ALL ON $database.* TO '$username'@'localhost' IDENTIFIED BY '$password';
|
|
|
|
GRANT ALL ON $database.* TO '$username'@'%' IDENTIFIED BY '$password';
|
2010-01-28 03:08:24 +09:00
|
|
|
INSERT INTO status_network (nickname, dbhost, dbuser, dbpass, dbname, sitename, created, tags)
|
|
|
|
VALUES ('$nickname', '$DBHOSTNAME', '$username', '$password', '$database', '$sitename', now(), '$tags');
|
2009-06-16 07:13:24 +09:00
|
|
|
|
|
|
|
ENDOFCOMMANDS
|
|
|
|
|
2009-06-24 02:43:50 +09:00
|
|
|
for top in $AVATARBASE $FILEBASE $BACKGROUNDBASE; do
|
|
|
|
mkdir $top/$nickname
|
|
|
|
chmod a+w $top/$nickname
|
|
|
|
done
|
2010-01-28 03:08:24 +09:00
|
|
|
|
|
|
|
php $PHPBASE/scripts/registeruser.php \
|
|
|
|
-s"$server" \
|
|
|
|
-n"$nickname" \
|
2010-01-28 09:03:01 +09:00
|
|
|
-f"$fullname" \
|
2010-01-28 03:08:24 +09:00
|
|
|
-w"$userpass" \
|
|
|
|
-e"$email"
|
|
|
|
|
|
|
|
for role in $roles
|
|
|
|
do
|
|
|
|
php $PHPBASE/scripts/userrole.php \
|
|
|
|
-s"$server" \
|
|
|
|
-n"$nickname" \
|
|
|
|
-r"$role"
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -f "$MAILTEMPLATE" ]
|
|
|
|
then
|
|
|
|
# fixme how safe is this? are sitenames sanitized?
|
|
|
|
cat $MAILTEMPLATE | \
|
|
|
|
sed "s/\$nickname/$nickname/" | \
|
|
|
|
sed "s/\$sitename/$sitename/" | \
|
|
|
|
sed "s/\$userpass/$userpass/" | \
|
|
|
|
php $PHPBASE/scripts/sendemail.php \
|
|
|
|
-s"$server" \
|
|
|
|
-n"$nickname" \
|
|
|
|
--subject="$MAILSUBJECT"
|
|
|
|
else
|
|
|
|
echo "No mail template, not sending email."
|
|
|
|
fi
|
2010-01-28 08:37:18 +09:00
|
|
|
|
|
|
|
if [ -f "$POSTINSTALL" ]
|
|
|
|
then
|
|
|
|
echo "Running $POSTINSTALL ..."
|
|
|
|
source "$POSTINSTALL"
|
|
|
|
fi
|