Free Web Hosting by Netfirms
Web Hosting by Netfirms | Free Domain Names by Netfirms

unix_commands

How to Setup Student Account on Speak

  • Description
  • We use a modified version of "adduser", which is an interactive perl script that will take care the procedure for adding a new user. What we did is changing it to read input from a file with a list of users. The format of the file is like this:

       <UniqueName>|<FullName>|<Password>

    The unique name and full name are taken from the log file of the web registration, called "email.txt". The password is retrieved from the user profiles of the ubb forum, stored at irl:/usr/local/www/reg-data/Members/.

    Therefore, we need to copy both the "email.txt" and the user profiles to the machine we will creates the accounts.

    The format of "email.txt" is following:

        # [Uniquename] Full Name

        email@address

    The format of user profile is

        `UserName'|`Passwd '|`Email'|`URL'|`Permission'|`Occupation'

               |`Address'|TotalPosts|`Status'|`Interest'|RegDate|EmailView|

    We use the bold fields of the above to generate the user list file. After you download the adduser package, you will find a script called "collect.pl", which will generate the user list file.

  • Creates Accounts
  • # login to the machine where the accounts will be created.
    ssh <machine>
    # add a new group called "eecs489"
    vi /etc/group
    mkdir /tmp/adduser
    chmod 700 /tmp/adduser
    cd /tmp/adduser
    # retrieve the file.
    fetch http://idmaps.eecs.umich.edu/crib/howto/eecs489/adduser.tgz
    tar xvfz adduser.tgz
    vi adduser.perl

      Line 367: sub new_user_home: Check the $userhome variable. We need to change the "f00" of "/home/eecs489/f00/$name" to the correct term.

      Line 444: sub new_user_grplogin: Check the $group_login variable. It should be "eecs489". Make sure that group "eecs489" exists.

      Line 745: There are two "system" commands, that will create a link to student course directory in the engin domain, and a link to the .x509v3 authentication file that is in their engin home directory. Modify the " f00" to correct term. Make sure the afs directory is correct, in case of the engin domain changes user's afs path.

    # copy email.txt from the web server.
    scp username@machine:/usr/local/www/reg-data/email.txt .
    mkdir user
    cd user
    scp username@machine:/usr/local/www/reg-data/Members/\*.cgi .
    cd ..
    # generate the user.txt
    collect.pl
    # add the user accounts.
    adduser.perl
    # clean up the tmp files
    cd ..
    rm -rf adduser

  • What we changed to adduser.perl?
    We changed 3 functions, new_user_home, new_user_grplogin and new_users. The following is the modified files.
    • new_user_home

      sub new_users_home {

          local($name) = @_;

          local($userhome);

       

          while(1) {

              $userhome = &confirm_list("Enter home directory (full path)", 1,

                  "/home/eecs489/f00/$name", "");

              last if $userhome =~ /^\//;

              warn qq{Home directory "$userhome" is not a full path\a\n};

          }

          return $userhome;

      }

      new_user_grplogin line:443

          while(1) {

              $group_login = "eecs489";

                    # &confirm_list("Login group", 1, $group, ($name, $group));

              last if $group_login eq $group;

              last if $group_login eq $name;

              last if defined $groupname{$group_login};

              if ($group_login eq $group_uniq) {

                  $group_login = $name; last;

              }

       

              if (defined $gid{$group_login}) {

                  # convert numeric groupname (gid) to groupname

                  $group_login = $gid{$group_login};

                  last;

              }

              warn "Group does not exist!\a\n";

          }

      new_user line:709

         

          $userfile = "user.txt";

          open( Fuser, $userfile );

          @lines = &lt;Fuser&gt;;

          for ($i = 0; $i &lt;= $#lines; $i++ ){

              @words = split( /\|/, $lines[$i] );

              $name = $words[0]; #&new_users_name;

              next if (&new_users_name_valid($name) ne $name);

              $fullname = $words[1]; #&new_users_fullname($name);

              next if $fullname ne &new_users_fullname_valid($fullname);

              $sh = &new_users_shell;

              $userhome = &new_users_home($name);

              ($u_id, $g_id) = &new_users_id($name);

              $class = &new_users_class($defaultclass);

              ($group_login, $defaultgroup) =

                  &new_users_grplogin($name, $defaultgroup, $new_users_ok);

              # do not use uniq username and login group

              $g_id = $groupname{$group_login} if (defined($groupname{$group_login}));

       

              $new_groups = &new_users_groups($name, $new_groups);

              #print "username= $words[0], passwd = $words[1]\n";

              $password = $words[2]; #&new_users_password;

       

              #if ( 1 ) { #&new_users_ok) {

                  $new_users_ok = 1;

       

                  $cryptpwd = "";

                  $cryptpwd = crypt($password, &salt) if $password ne "";

                  # obscure perl bug

                  $new_entry = "$name\:" . "$cryptpwd" .

                      "\:$u_id\:$g_id\:$class\:0:0:$fullname:$userhome:$sh";

                  &append_file($etc_passwd, "$new_entry");

                  &new_users_pwdmkdb("$new_entry");

                  &new_users_group_update;

                  &new_users_passwd_update;  print "Added user ``$name''\n";

                  #&new_users_sendmessage;

                  #&adduser_log("$name:*:$u_id:$g_id($group_login):$fullname ");

                  &home_create($userhome, $name, $group_login);

                  system ("ln -s /afs/engin.umich.edu/class/f00/eecs489/students/$name

       $userhome/eecs489");

                  ($name1c, $name2c) = ($name =~ /^(\w)(\w)/);

                  system ("ln -s /afs/engin.umich.edu/u/$name1c/$name2c/$name/.x509v3

      $userhome/.x509v3");

          }

          printf "end.\n";

       

       

       

       

       add '.' to the path variable. Line:1010

       

         system("cp -f dot.cshrc $homedir");