Announcement

Collapse
No announcement yet.

my UseraddScript doesnt work

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • my UseraddScript doesnt work

    This is my script which runs perfectly under SUSE but in ubuntu i got only this message:

    ./oxadmin: line 62: syntax error near unexpected token `done'
    ./oxadmin: line 62: ` done'

    What can i do to run this script? I have to create more than 200 Accounts and all by copy paste and the normal way i can give me the gun.

    And when someone read this here, i have the problem to set the services (groupware/admin) in autostart bzw. runlevel.

    Hope anybody can help

    Code:
    -----------------------start--------------------------------------------------------
    
    #===========================================================================#
    
    #===========================================================================#
    
    TELNET="telnet"
    IMAPSERVER="localhost"
    IMAPPORT="imap"
    IMAPFOLDERS="gesendet Papierkorb Ablage SPAM"
    CYRUS="oxadmin"
    PASSWORD="mypass"
    DOMAIN="schmidt-mg.de"
    
    
    clear
    while true
    do
    echo " #=================================================================#"
    echo " # OX 6 Benutzerverwaltung
    echo " #=================================================================#"
    echo " # OpenExchange administration menu #"
    echo " # a) Adduser #"  
    echo " # b) Change User Password #" PLS DONT USE
    echo " # c) Addresource #"
    echo " # d) Delete User #" PLS DONT USE
    echo " # e) Add Group #" PLS DONT USE
    echo " # f) Delete Group #" PLS DONT USE
    echo " # q) quit from this menu #" 
    echo " #=================================================================#"
    echo " #=================================================================#"
    
    read WAR
    case $WAR in
    
    a|A) echo " Please wait "
    clear
    echo " Bitte geben Sie den gewuenschten Benutzernamen ein: "
    read UNAME
    echo " Bitte geben Sie den Vornamen ein: "
    read GNAME
    echo " Bitte geben Sie den Nachnamen ein: "
    read SNAME
    echo " Bitte geben Sie das gewuenschte Passwort ein: "
    read PASSWD
    echo " Bitte geben Sie die Abteilung des Benutzers an: (HSR_/HSK_... Buch,Rech,EK,VKT1,VKT2,GL,...) "
    read GRP
    echo " Bitte geben Sie das Postfach des externen Anbieters an: "
    read POST
    echo " Moechten Sie diesen Benutzer zum Symstem hinzufuegen? (y|n) "
    read WAR
    case $WAR in
    
    y|Y) echo " Please wait "
    
    /opt/open-xchange/sbin/createuser -A oxadmin -P "mypass" --username $UNAME --displayname "$GNAME $SNAME" --password $PASSWD --email $UNAME@schmidt-mg.de --givenname $GNAME --surname $SNAME --language de_DE --timezone Europe/Berlin --department $GRP --company "Heinrich Schmidt GmbH & Co. KG"
    
    
    echo "+++++++++++++++++++++++++++++++++++++++"
    echo "+ Erstelle Mailbox fuer user $USERNAME +"
    echo "+++++++++++++++++++++++++++++++++++++++"
    #now create user's mailbox
    (echo . login $CYRUS $PASSWORD
    sleep 1
    for uid in $UNAME; do
            echo . create user/$uid
                        sleep 1
                        done
                        done
                        echo . logout
                        sleep 1
    ) | $TELNET $IMAPSERVER $IMAPPORT
    #useradd $NAME -c $PASSWD
    #passwd $NAME
    #saslpasswd2 $NAME
    #echo user "'"$UNAME"@schmidt-mg.de'" with password "'"$PASSWD"'" is $NAME here >>/etc/fetchmailrc
    ;;
    n|N) exit 1
    ;;
    *) invalid request
    ;;
    
    esac
    
    echo " do you want to continue ? (y|n) "
    read WAS
    case $WAS in
    
    y|Y) echo " Please wait "
    clear
    ;;
    n|N) echo " Thank you for using this script"
    echo " For any suggestion , please email to pokemontel@yahoo.com"
    exit 2
    ;;
    *) echo "invalid request"
    ;;
    esac
    
    ;;
    
    c|C) echo " Please wait "
    clear
    echo " Please insert the resource to add to the system. "
    read NAME
    echo " Please insert the Username of the responisble Person for the ressource. "
    read RNAME
    echo " Is it available for booking? (true/false) "
    read AVA
    echo " Description for the ressource: "
    read DES
    
    echo " Do you want to add this resources $NAME to the system ? (y|n) "
    read WAR
    
    case $WAR in
    y|Y) echo " Please wait "
    /opt/open-xchange/sbin/createresource -A oxadmin -P "mypass" --name $NAME --displayname "$NAME" --email $RNAME@schmidt-mg.de --available $AVA --description "$DES"
    ;;
    
    n|N) exit 1
    ;;
    *) invalid request
    ;;
    esac
    ;;
    
    d|D) echo " Please wait"
    clear
    echo " Please insert the username to delete from the system. "
    read NAME
    
    echo " do you want to permanent to delete this user $NAME ? (y|n) "
    read WAR
    
    case $WAR in
    
    y|Y) echo " Please wait "
    /opt/ox/sbin/deluser_ox --username=$NAME
    userdel $NAME
    ;;
    n|N) exit 1
    ;;
    *) invalid request
    ;;
    esac
    ;;
    e|E) echo " Please wait"
    clear
    echo " Please insert the groupname to create . "
    read NAME
    
    echo " do you want to create this group < $NAME> to the system ? (y|n) "
    read WAR
    
    case $WAR in
    
    y|Y) echo " Please wait "
    /opt/ox/sbin/addgroup_ox --group=$NAME
    ;;
    n|N) exit 1
    ;;
    *) invalid request
    ;;
    esac
    ;;
    
    f|F) echo " Please wait"
    clear
    echo " Please insert the group to delete from the system. "
    read NAME
    
    echo " do you want to permanent to delete this group $NAME ? (y|n) "
    read WAR
    
    case $WAR in
    
    y|Y) echo " Please wait "
    /opt/ox/sbin/delgroup_ox --username=$NAME
    ;;
    n|N) exit 1
    ;;
    *) invalid request
    ;;
    esac
    ;;
    
    q|Q) exit 0
    
    ;;
    *) echo "invalid request"
    ;;
    
    esac
    
    echo " Back to the main menu ? (y|n) "
    read WAS
    case $WAS in
    
    y|Y) echo " Please wait "
    clear
    ;;
    n|N) echo " Thank you for using this script"
    echo " For any suggestion , please email to pokemontel@yahoo.com"
    exit 2
    ;;
    *) echo "invalid request"
    ;;
    esac
    done

  • #2
    Originally posted by altariq View Post
    This is my script which runs perfectly under SUSE but in ubuntu i got only this message:

    ./oxadmin: line 62: syntax error near unexpected token `done'
    ./oxadmin: line 62: ` done'

    What can i do to run this script? I have to create more than 200 Accounts and all by copy paste and the normal way i can give me the gun.

    And when someone read this here, i have the problem to set the services (groupware/admin) in autostart bzw. runlevel.

    Hope anybody can help
    [...]
    Why don't you use

    /opt/open-xchange/sbin/createuser

    ?

    Comment


    • #3
      createuser doesnt create a cyrus mailbox. Maybe it does but than my cyrus is configured wrong.

      That script creates with not much work a OX User, Cyrus User and fills my fetchmailrc with the right command for fetching emails.
      creatuser is to complicated when you want to create more than 100 Users.
      My solution should be a ox-server with cyrus, fetchmail, postfix and amavis. But unfortunatly te howto i wanted to use (linux-tin.org) is not longer available.

      Comment


      • #4
        Something runs wrong here:

        Code:
        root@schmidt-mg:~# /opt/open-xchange/sbin/deleteuser -A oxadmin -P "mypass" -i 3
        Server response:
         java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`open-xchange-db/oxfolder_tree`, CONSTRAINT `oxfolder_tree_ibfk_1` FOREIGN KEY (`cid`, `created_from`) REFERENCES `user` (`cid`, `id`))
        Code:
        root@schmidt-mg:~# /opt/open-xchange/sbin/createuser -A oxadmin -P "mypass" --username d.bongatz --displayname "Dorothe Bongartz" --password userpass --email d.bongartz@schmidt-mg.de --givenname Dorothe --surname Bongartz --language de_DE --timezone Europe/Berlin --department EDV --company "Heinrich Schmidt GmbH & Co. KG"
        6
        root@schmidt-mg:~# /opt/open-xchange/sbin/deleteuser -A oxadmin -P "mypass" -i 6
        Server response:
         java.sql.SQLException: Cannot delete or update a parent row: a foreign key constraint fails (`open-xchange-db/oxfolder_tree`, CONSTRAINT `oxfolder_tree_ibfk_1` FOREIGN KEY (`cid`, `created_from`) REFERENCES `user` (`cid`, `id`))
        root@schmidt-mg:~#

        Comment

        Working...
        X