#1  
Old 4th April 2007, 17:51
webking webking is offline
Junior Member
 
Join Date: Mar 2007
Posts: 29
Thanks: 3
Thanked 0 Times in 0 Posts
Wink Shell Scripting Help...

Hi all,

How difficult is it to get this pseudo code to work under SHELL? This is the task I do every day. I m not sure how to start it. can anyone help?

useradd username
usermod -g username username
passwd username
vi /etc/passwd
define home dir
cd ~username
remove all data
then go to /home/usrbak
cp username.tar.gz to /tmp
cd tmp
gzip -d username.tar.gz
tar -xf username.tar
mv * ~username
vi /usr/local/apache/conf/include-conf/vhosts
add the domain within the vhost
cd ~username
chown -R username:username .
chmod -R 755 .
service httpd restart

Any assistance would be helpful. Thanks in adv.
Reply With Quote
Sponsored Links
  #2  
Old 5th April 2007, 18:28
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,747 Times in 2,578 Posts
Default

You could write a little script for it.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 19th April 2007, 19:13
cfajohnson cfajohnson is offline
Junior Member
 
Join Date: Apr 2007
Location: Toronto, Canada
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default


Most of what you are doing can be done with useradd itself. Read the man page.

The (moderately) tricky part is encrypting the password. I use a compiled C program as a front end to crypt(3):

/********************************
NAME: crypt.c
AUTHOR: Chris F.A. Johnson
DATE: 2003-01-23
********************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

int
main(int argc, char *argv[])
{
char *passwd;
char buf[1024];
char *salt;

if (argc > 1)
{
salt = argv[1];
puts(salt);
}
else
{
/* salt = "$1$!@#$%^&*"; */
salt = NULL;
}

fgets(buf,sizeof(buf),stdin);
if ( buf[strlen(buf)-1] == '\n' )
{
buf[strlen(buf) - 1] = '\0';
}
printf( "%s\n", encrypt(buf, salt));

return 0;
}
/********************************/

Do not use vi in a script. Describe what you want to do, and script it directly.
Reply With Quote
  #4  
Old 19th April 2007, 20:13
sjau sjau is offline
Local Meanie
 
Join Date: Apr 2006
Location: Switzerland
Posts: 1,149
Thanks: 4
Thanked 56 Times in 52 Posts
Default

Well, I think it's not that hard to make a bash script that does this...
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPC 2.2.9: Invalid user shell on Ubuntu/Debian martinfst Developers' Forum 4 13th January 2007 16:28
need urgent help for writing shell script dips Programming/Scripts 8 3rd September 2006 20:40
php scripting and shell commands alexnz Programming/Scripts 3 8th August 2006 17:30
Shell nveid General 5 27th March 2006 15:49
Impressive shell scripting namit Programming/Scripts 8 25th March 2006 16:50


All times are GMT +2. The time now is 15:28.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.