Adding and removing blog users
This commit is contained in:
parent
5ee011f200
commit
e814591808
|
@ -1236,6 +1236,15 @@ function mark_admin_user_account {
|
|||
fi
|
||||
}
|
||||
|
||||
function mark_blog_domain {
|
||||
if [[ $SYSTEM_TYPE == "$VARIANT_CLOUD" || $SYSTEM_TYPE == "$VARIANT_MAILBOX" || $SYSTEM_TYPE == "$VARIANT_CHAT" || $SYSTEM_TYPE == "$VARIANT_SOCIAL" || $SYSTEM_TYPE == "$VARIANT_MEDIA" || $SYSTEM_TYPE == "$VARIANT_DEVELOPER" || $SYSTEM_TYPE == "$VARIANT_MESH" ]]; then
|
||||
return
|
||||
fi
|
||||
if ! grep -q "Blog domain:" $COMPLETION_FILE; then
|
||||
echo "Blog domain:$FULLBLOG_DOMAIN_NAME" >> $COMPLETION_FILE
|
||||
fi
|
||||
}
|
||||
|
||||
function randomize_cron {
|
||||
# The predictable default timing of Debian cron jobs might
|
||||
# be exploitable knowledge. Avoid too much predictability
|
||||
|
@ -10925,6 +10934,7 @@ configure_firewall_for_irc
|
|||
install_voip
|
||||
install_wiki
|
||||
install_blog
|
||||
mark_blog_domain
|
||||
install_gnu_social
|
||||
install_hubzilla
|
||||
install_dlna_server
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
MY_USERNAME=$1
|
||||
GPG_KEYSERVER='hkp://keys.gnupg.net'
|
||||
SSH_PORT=2222
|
||||
COMPLETION_FILE=$HOME/freedombone-completed.txt
|
||||
|
||||
if [ ! $MY_USERNAME ]; then
|
||||
echo 'No username was given'
|
||||
|
@ -13,19 +14,25 @@ if [ -d /home/$MY_USERNAME ]; then
|
|||
exit 2
|
||||
fi
|
||||
|
||||
if [ ! -f $COMPLETION_FILE ]; then
|
||||
echo "$COMPLETION_FILE not found"
|
||||
userdel -r $MY_USERNAME
|
||||
exit 3
|
||||
fi
|
||||
|
||||
NEW_USER_PASSWORD="$(openssl rand -base64 10 | cut -c1-8)"
|
||||
useradd -m -p "$NEW_USER_PASSWORD" -s /bin/bash $MY_USERNAME
|
||||
adduser $MY_USERNAME sasl
|
||||
|
||||
if [ ! -d /home/$MY_USERNAME ]; then
|
||||
echo 'Home directory was not created'
|
||||
exit 3
|
||||
exit 4
|
||||
fi
|
||||
|
||||
if [ ! -d /home/$MY_USERNAME/Maildir ]; then
|
||||
echo 'Email directory was not created'
|
||||
userdel -r $MY_USERNAME
|
||||
exit 4
|
||||
exit 5
|
||||
fi
|
||||
|
||||
if grep -q "set from=" /home/$MY_USERNAME/.muttrc; then
|
||||
|
@ -69,7 +76,7 @@ su -c "gpg --output $MY_GPG_PUBLIC_KEY --armor --export $MY_GPG_PUBLIC_KEY_ID" -
|
|||
if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
|
||||
echo "GPG public key was not generated for $MY_USERNAME@$HOSTNAME $MY_GPG_PUBLIC_KEY_ID"
|
||||
userdel -r $MY_USERNAME
|
||||
exit 5
|
||||
exit 6
|
||||
fi
|
||||
|
||||
# encrypt outgoing mail to the "sent" folder
|
||||
|
@ -123,7 +130,22 @@ freedombone-addxmpp -e "$MY_USERNAME@$HOSTNAME" -p "$NEW_USER_PASSWORD"
|
|||
if [ ! "$?" = "0" ]; then
|
||||
echo "XMPP account not created"
|
||||
userdel -r $MY_USERNAME
|
||||
exit 6
|
||||
exit 7
|
||||
fi
|
||||
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
if [ ! -d /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users ]; then
|
||||
echo 'Blog users directory not found'
|
||||
userdel -r $MY_USERNAME
|
||||
exit 8
|
||||
fi
|
||||
echo ';Password' > /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo "password = '$NEW_USER_PASSWORD'" >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'encryption = clear' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo ';Role' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo 'role = admin' >> /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
echo "$MY_USERNAME added as a blog user"
|
||||
fi
|
||||
|
||||
clear
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/bash
|
||||
|
||||
MY_USERNAME=$1
|
||||
COMPLETION_FILE=$HOME/freedombone-completed.txt
|
||||
|
||||
if [ ! $MY_USERNAME ]; then
|
||||
echo 'Please specify a username to remove'
|
||||
|
@ -12,7 +13,6 @@ if [ ! -d /home/$MY_USERNAME ]; then
|
|||
exit 2
|
||||
fi
|
||||
|
||||
COMPLETION_FILE=$HOME/freedombone-completed.txt
|
||||
if [ ! -f $COMPLETION_FILE ]; then
|
||||
echo "$COMPLETION_FILE not found"
|
||||
exit 3
|
||||
|
@ -43,6 +43,13 @@ fi
|
|||
|
||||
freedombone-rmxmpp -e "$MY_USERNAME@$HOSTNAME"
|
||||
|
||||
if grep -q "Blog domain" $COMPLETION_FILE; then
|
||||
FULLBLOG_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Blog domain" | awk -F ':' '{print $2}')
|
||||
if [ -f /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini ]; then
|
||||
rm /var/www/$FULLBLOG_DOMAIN_NAME/htdocs/config/users/$MY_USERNAME.ini
|
||||
fi
|
||||
fi
|
||||
|
||||
userdel -r $MY_USERNAME
|
||||
|
||||
if [ -d /home/$MY_USERNAME ]; then
|
||||
|
|
Loading…
Reference in New Issue