[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

RE: [K12OSN] Win4Lin which version and how much?



Hi Mark,

As I understand it, this script creates the Win4Lin installation for each 
user 'on the fly'.

Does it clean up afterwards?

I've created generic users that I call "machine" users. This means I have 
around 35 users with essentially the same setups using a lot of drive 
space.

Could you send me an explanation of what happens?

Thanks,
Bert

On Tuesday, May 07, 2002 10:39 PM, Mark Evans 
[SMTP:mpe st-peters-high devon sch uk] wrote:
> > I tested the network version of win4lin and found several problems. 
It's
> > been several months but here's what I recall...
> >
> > You have to have a full win95 install for each user, even with the 
full,
> > multi user version. If you have 100 users, you need 100 installs of
> > win95.  I got around this by creating generic win4lin users like
> > windows1 and windows2 for each workstation.
>
> Actually you don't.
>
> > The multiuser version will not work if /home is mounted via nfs. My
> > workaround above solved the problem after making the home directory for
> > the windows1 user point to a local folder on the ltsp server instead of
> > something in /home. This means that the user launches win4lin and then
> > logs in again to the windows workstation. Run samba on the ltsp server
> > and map a /home share to /home and you get your home folders.
>
> I have a rather simpler solution.
> /bin/win is replaced with the following script
>
> #!/bin/sh
> echo Creating Windows setup, please wait
> export WIN4LIN=/usr/share/win4lin/$DISPLAY
> /bin/wingen
> chmod 644 $WIN4LIN/command.com
> rm -f $WIN4LIN/windows/spool/PRINTERS/*
> mkdir $WIN4LIN/RECYCLED
> mkdir $WIN4LIN/temp
> mkdir $WIN4LIN/windows/temp
> if [ ! -d ~/Favorites ]; then
>   rm -rf ~/Favorites
>   mkdir ~/Favorites
> fi
> if [ ! -d ~/History ]; then
>   rm -rf ~/History
>   mkdir ~/History
> fi
> ln -s ~/History $WIN4LIN/windows/History
> if [ ! -d ~/Cookies ]; then
>   rm -rf ~/Cookies
>   mkdir ~/Cookies
> fi
> ln -s ~/Cookies $WIN4LIN/windows/Cookies
> if [ ! -d ~/Recent ]; then
>   rm -rf ~/Recent
>   mkdir ~/Recent
> fi
> ln -s ~/Recent $WIN4LIN/windows/Recent
> /bin/nsgen
> ln -s ~/.ns_win $WIN4LIN/Program\ Files/Netscape/Users/default
> rm -f ~/.merge
> ln -fs /usr/share/merge ~/.merge
> /opt/win4lin/publicbin/win
> chmod 644 $WIN4LIN/command.com
>
> The source for /bin/wingen
>
> #include <stdio.h>
> #include <sys/types.h>
> #include <sys/stat.h>
> #include <unistd.h>
> #include <dirent.h>
> #include <utime.h>
> #include <fcntl.h>
> #include <errno.h>
>
> char old[BUFSIZ], new[BUFSIZ];
> int uid, gid;
>
> char prefix[]="/usr/share/win4lin";
>
> void set_attr(char *name, struct stat *st)
> {
>     struct utimbuf utb;
>
>     utb.actime=st->st_atime;
>     utb.modtime=st->st_mtime;
>     utime (name, &utb);
>     chown (name, getuid(), getgid());
> //    chown (name, st->st_uid, st->st_gid);
>     chmod (name, st->st_mode);
> }
>
> void copy_file(char *from, char *to, struct stat *st)
> {
>     unlink(to);
>     if (S_ISREG(st->st_mode))
>     {
> 	char buf [BUFSIZ];
> 	int n_read;
> 	int i=open(from, O_RDONLY);
> 	int o=open(to, O_WRONLY | O_CREAT | O_TRUNC, 0600);
>
> 	if ((i<0) || (o<0))
> 	{
> 	   close(o);
> 	   close(i);
> 	   return;
> 	}
>         for (;;)
> 	{
> 	    n_read=read(i,buf,BUFSIZ);
> 	    if (n_read < 0)
> 	    {
> 		if (errno == EINTR) continue;
> 		close (o);
> 		close (i);
> 		return;
> 	    }
> 	    if (n_read == 0) break;
> 	    write(o,buf,n_read);
> 	}
> 	close (o);
> 	close (i);
>     }
>     if (S_ISLNK(st->st_mode))
>     {
> 	char link_val[BUFSIZ];
> 	int link_size=readlink(from, link_val, BUFSIZ);
>
> 	if (link_size <0) return;
> 	link_val[link_size]='\0';
> 	if (symlink (link_val, to)) return;
>     }
>     if (S_ISFIFO(st->st_mode))
> 	mkfifo(to, st->st_mode);
>
>     if ((S_ISBLK(st->st_mode)) || (S_ISCHR(st->st_mode)) || 
(S_ISSOCK(st->st_mode)))
> 	mknod(to, st->st_mode, st->st_rdev);
>
>     set_attr(to, st);
> }
>
> void rm_file(char *name)
> {
>     DIR *dir;
>     struct dirent *dirent;
>     char n[BUFSIZ];
>     struct stat st;
>
>     if ((lstat(name,&st))==-1) return;
>
>     if (!S_ISDIR(st.st_mode))
>     {
>         unlink(name);
>         return;
>     }
>
>     if ((dir=opendir(name))!=0)
>     {
> 	while (dirent=readdir(dir))
>             {
> 	        if (strcmp(dirent->d_name,".")==0) continue;
> 		if (strcmp(dirent->d_name,"..")==0) continue;
>     		sprintf(n,"%s/%s", name, dirent->d_name);
>                 rm_file (n);
>             }
> 	closedir(dir);
>     }
>     rmdir (name);
> }
>
> void handle_dir(char *source, char *dest)
> {
>     DIR *dir;
>     struct dirent *dirent;
>     char path[BUFSIZ];
>     char cur[BUFSIZ];
>     char file_s[BUFSIZ];
>     char file_d[BUFSIZ];
>     char s[BUFSIZ];
>     char d[BUFSIZ];
>     struct stat s_st;
>     struct stat d_st;
>
>     stat(source,&s_st);
>     if ((stat(dest,&d_st)) == -1) mkdir (dest, s_st.st_mode);
>
>
>     if ((dir=opendir(source))!=0)
>     {
> 	while (dirent=readdir(dir))
>             {
> 		if (strcmp(dirent->d_name,".")==0) continue;
> 		if (strcmp(dirent->d_name,"..")==0) continue;
> 		if (strcmp(dirent->d_name,".merge_win95_lock")==0) continue;
> 		if (strcmp(dirent->d_name,"RECYCLED")==0) continue;
> 		if (strcmp(dirent->d_name,"temp")==0) continue;
> 		if (strcmp(dirent->d_name,"default")==0) continue;
> 		if (strcmp(dirent->d_name,"Favorites")==0) continue;
> 		if (strcmp(dirent->d_name,"History")==0) continue;
> 		if (strcmp(dirent->d_name,"Cookies")==0) continue;
> 		if (strcmp(dirent->d_name,"AfW")==0) continue;
> 		if (strcmp(dirent->d_name,"Temporay Internet Files")==0) continue;
>     		sprintf(s,"%s/%s", source, dirent->d_name);
>     		sprintf(d,"%s/%s", dest, dirent->d_name);
> 		lstat (s, &s_st);
> 		if (S_ISDIR(s_st.st_mode))
>                 {
>                     handle_dir(s, d);
>                     continue;
>                 }
> 		if ((strcmp(dirent->d_name,"system.dat")==0) || 
 (strcmp(dirent->d_name,"user.dat")==0) || 
(strcmp(dirent->d_name,"nsreg.dat")==0))
>                 {
>                     copy_file(s, d, &s_st);
>                     continue;
>                 }
> 	        link (s, d);
>             }
> 	closedir(dir);
>     }
>
>     if ((dir=opendir(dest))!=0)
>     {
> 	while (dirent=readdir(dir))
>             {
> 		if (strcmp(dirent->d_name,".")==0) continue;
> 		if (strcmp(dirent->d_name,"..")==0) continue;
>
>     		sprintf(s,"%s/%s", source, dirent->d_name);
>     		sprintf(d,"%s/%s", dest, dirent->d_name);
>
>                 if ((lstat(s,&s_st)) == -1)
>                     rm_file(d);
>
> 		if (strcmp(dirent->d_name,"RECYCLED")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"temp")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"default")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"Favorites")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"Cookies")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"History")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"AfW")==0) rm_file(d);
> 		if (strcmp(dirent->d_name,"Temporay Internet Files")==0) rm_file(d);
>             }
> 	closedir(dir);
>     }
>
>     chown (dest, getuid(), getgid());
>     return;
> }
>
> main (int argc, char **argv)
> {
>     char f[BUFSIZ];
>     char source[BUFSIZ], dest[BUFSIZ];
>     FILE *st;
>     char *display=getenv("DISPLAY");
>     uid=getuid();
>     gid=getgid();
>
>     sprintf(source,"%s/:0", prefix);
>
>     if (strcmp(display, ":0")==0)
>     {
>         sprintf (f,"%s/RECYCLED", source);
>         rm_file (f);
>         sprintf (f,"%s/temp", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/Recent", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/Cookies", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/History", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/Favorites", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/temp", source);
>         rm_file (f);
>         sprintf (f,"%s/windows/AfW", source);
>         rm_file (f);
>         sprintf (f,"%s/Program Files/Netscape/Users/default", source);
>         rm_file (f);
>     }
>     else
>     {
>
>         sprintf(dest,"%s/%s", prefix ,display );
>
>         handle_dir(source, dest);
>
>         sprintf (f,"%s/windows/Recent", dest);
>         rm_file (f);
>     }
> }
>
>
>
>
> _______________________________________________
> K12OSN mailing list
> K12OSN redhat com
> https://listman.redhat.com/mailman/listinfo/k12osn
> For more info see <http://www.k12os.org>
> 






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]