#!/usr/bin/sh # This script creates the missing accounts for rss feeds # Il reads the /etc/bolixo/rssd.conf HOSTNAME=`hostname` BO=bo BOFS=bofs RSSD=rssd CALLTEST="bo calltest" CONFIG=/etc/bolixo/rssd.conf.d . $HOME/bolixo.conf UPDPHOTO= PUBLISH= ACCOUNT= PUBTHISNODE=$THISNODE if [ "$PREPRODOPTION" != "" ] ; then PUBTHISNODE=https://preprod.bolixo.org fi while [ $# != 0 ] do if [ "$1" = "debug" ] ; then BO=./test.sh BOFS=./bofs RSSD=./rssd CALLTEST=./test.sh CONFIG=../rssd.conf.d elif [ "$1" = "updphoto" -a "$2" != "" ] ; then UPDPHOTO=$2 shift elif [ "$1" = "publish" -a "$2" != "" ] ; then PUBLISH=$2 shift elif [ "$1" = "account" -a "$2" != "" ] ; then ACCOUNT=$2 shift elif [ "$1" = "pubthisnode" -a "$2" != "" ] ; then PUBTHISNODE=$2 shift elif [ "$1" = "help" ] ; then echo create-rss-account [ options ] echo Options are: echo " account one-account" echo " updphoto one-account" echo " publish one-account" echo " pubthisnode alternate-name-for-this-server" exit 1 else echo Invalid option $1 exit 1 fi shift done rm -fr /tmp/cacheurl.dir $BO mailctrl 0 keep $RSSD --config $CONFIG --printaccounts | while read acc do if [ "$ACCOUNT" != "" -a "$ACCOUNT" != "$acc" ] ; then continue fi nb=`$BO files --silent <<-EOF select count(*) from id2name where name='$acc'; EOF ` if [ "$nb" = 0 ] ; then $CALLTEST bo-writed-control adduser $acc $acc@$HOSTNAME "" eng \ && $CALLTEST bo-writed-control confirmuser $acc # Disable accounts. No one should log to this $CALLTEST bo-writed-control disable $acc # Make the account visible (public page) echo bofs -u admin misc --owner $acc -w -V 1 $BOFS -u admin misc --owner $acc -w -V 1 fi # Get photos and upload to bolixo if [ "$nb" = 0 -o "$UPDPHOTO" = "$acc" -o "$UPDPHOTO" = all ] ; then if [ "$UPDPHOTO" = all ] ; then echo Update photo for account $acc fi DIR=/var/lib/rssd/images/$acc mkdir -p $DIR URL=`$RSSD --config $CONFIG --printfield mini_photo_url --account $acc` if [ "$URL" != "" ] ;then echo Retrieve mini-photo for account $acc rm -fr /tmp/download mkdir /tmp/download rm -f $DIR/mini-photo.jpg FILE=/tmp/download/`basename $URL` if ! /usr/lib/cacheurl --get --url $URL --file $FILE then if ! wget --directory-prefix /tmp/download --no-verbose $URL then echo wget failed exit 1 fi /usr/lib/cacheurl --save --url $URL --file $FILE fi case $FILE in /tmp/download/*.ico) echo ICO convert $FILE[3] -background white -thumbnail 40x -alpha on -flatten $DIR/mini-photo.jpg convert $FILE[3] -background white -thumbnail 40x -alpha on -flatten $DIR/mini-photo.jpg ;; *) echo OTHER convert /tmp/download/* -background white -thumbnail 40x -flatten $DIR/mini-photo.jpg convert $FILE -background white -thumbnail 40x -flatten $DIR/mini-photo.jpg ;; esac fi URL=`$RSSD --config $CONFIG --printfield photo_url --account $acc` if [ "$URL" != "" ] ;then echo Retrieve photo for account $acc rm -fr /tmp/download mkdir /tmp/download rm -f $DIR/photo.jpg FILE=/tmp/download/`basename $URL` if ! /usr/lib/cacheurl --get --url $URL --file $FILE then if ! wget --directory-prefix /tmp/download --no-verbose $URL then echo wget failed exit 1 fi /usr/lib/cacheurl --save --url $URL --file $FILE fi convert $FILE -background white -flatten -resize 100x $DIR/photo.jpg fi # RSS account can't log since they are disabled SESSION=`bo calltest bo-writed-control login $acc` test -f $DIR/mini-photo.jpg && \ $BOFS --session $SESSION cp $DIR/mini-photo.jpg bo://projects/$acc/public/mini-photo.jpg test -f $DIR/photo.jpg && \ $BOFS --session $SESSION cp $DIR/photo.jpg bo://projects/$acc/public/photo.jpg $BOFS --logout --session $SESSION fi # Publish to the directory bolixo.org if [ "$nb" = 0 -o "$PUBLISH" = "$acc" -o "$PUBLISH" = all ] ; then if [ "$PUBLISH" = all ] ; then echo Publish account $acc fi DIR=/var/lib/rssd/images/$acc CITY=`rssd --printfield city --account $acc` STATE=`rssd --printfield state --account $acc` COUNTRY=`rssd --printfield country --account $acc` WEBSITE=`rssd --printfield siteurl --account $acc` FULLNAME=`rssd --printfield name --account $acc` DEPTNAME=`rssd --printfield deptname --account $acc;` LANG=`rssd --printfield lang --account $acc` INTEREST="$FULLNAME $DEPTNAME
" if [ "$LANG" = "fr" ] ; then INTEREST="$INTEREST Compte RSS créé par l'équipe Bolixo" else INTEREST="$INTEREST RSS account created by the Bolixo team" fi SESSION=`bo calltest bo-writed-control login $acc` $BOFS --session $SESSION bolixoapi \ --publish \ --fullname "$FULLNAME" \ --city "$CITY" \ --state "$STATE" \ --country "$COUNTRY" \ --publish_bosite \ --website "$WEBSITE" \ --interest "$INTEREST" \ --publish_photo \ --publish_mini_photo \ infowrite $BOFS --logout --session $SESSION fi done $BO mailctrl 1 keep