Add to Favourites Add to Favourites    Print this Article Print this Article

Change the package for all Users to one value

If you wish to change the package from one value to another for all Users, you could use a script similar to the following:

#!/bin/sh

OLD=custom
NEW=fancy

for i in `ls /usr/local/directadmin/data/users`; do
{
       COUNT=`grep -c usertype=user /usr/local/directadmin/data/users/$i/user.conf`
       if [ "$COUNT" -eq 0 ]; then
               continue;
       fi

       echo "Updating User $i";

       perl -pi -e "s/package=$OLD/package=$NEW/" /usr/local/directadmin/data/users/$i/user.conf
};
done;
exit 0;

which will change all Users who have a custom package, to have a "fancy" package.

Then to activate the values in the user.conf, you'd simply save or edit the fancy package, and all Users with it will be updated accordingly.

Was this answer helpful?

Also Read