Linux Mouse

This was taken from http://dorward.me.uk/linux/mouse/ It seems to work.

I am not a big fan of Microsoft, but I will admit that they sometimes manage to produce (or at least brand) some nice hardware. The IntelliMouse Explorer comes with four buttons and a wheel, and its possible to use all of these under Linux.

I'm going to assume that you have all the required software already installed, if you get "command not found" at any time, you should seek out and install the softwere (which can probably be found on your distro's install disks.

* XFree
* Xmodmap
* imwheel

XFree

First you need to configure X to see the mouse and all its buttons. The following is taken from my /etc/X11/XF86Config-4 file.

Section "InputDevice"
# Make sure you use the identifier specified in the
# ServerLayout section.
Identifier "IntelliMouse"
Driver "mouse"
Option "Protocol" "ExplorerPS/2"
# Change the device to point to the correct location!
# I use the USB connection under devfs
Option "Device" "/dev/usbmouse"
Option "Buttons" "7"
Option "ZAxisMapping" "6 7"
EndSection

There are 7 buttons becuase the wheel counts as 3 (up, down, and click).
Xmodmap

Run xmodmap -e "pointer = 1 2 3 6 7 4 5". This has to be done everytime you login. I have the command in my ~/.xinitrc, but where you put it depends on your configuration. KDE users should look at ~/.kde/Autostart.

You can test to see if the extra buttons are seen by X with "xev" (place the pointer in the square and click the buttons to see the events).
imwheel

Next the mouse clicks have to be translated in to something the applications can understand. This is done by imwheel, which will let you specify keyboard commands for each click. We will configure it to send keyboard shortcuts for back and forwards to all applications. You can specify different combinations, either for all apps or for specific ones.

Create .imwheelrc in your home directory with the following:

".*"
None, Up, Alt_L|Left
None, Down, Alt_L|Right

Next start imwheel with imwheel -k -b "67". This also has to be done every time, so I have the command in ~/.xinitrc.

Linux and AD

Below are the proceedures I used to attach a Suse 9.0 Linux Box to a Windows 2000 Active Directory using the Windows authentication with windows users and groups.


1. Install Samba 3.0.2. I installed the entire Samba package. I'm unsure if all is required but just to be on the safe side I did. www.samba.org.


2. Copy in the requried portions of /etc/samab/smb.conf.


3. Copy in the required portions of the /etc/krb5.conf.


4. Copy in the required portions of the /etc/nsswitch.conf


5. Restart SMB and Winbind


6. Run net ads join -U will. It should ask for your password and then create the machine account and set the password.


7. As root run 'kinit will@AGHEALTH123.COM. This should ask for a password and then return to a prompt with no errors. If you incurr any erros then stop at this point and troubleshoot.


8. Run wbinfo -u to verify you receive all the AD users.


9. Run wbinfo -g to verify you receive all the AD groups.


10. Run getent passwd.


11. Run getent group.


12. If you want the user to have a home directory you need to create the home dir, such as /home/AGHEALTH123/will, and give the user access.

Misc Linux commands

Mount Windows Shares
mount -t smbfs -o username=will,password=password //10.13.1.12/music /home/will/music

Join Domain
smbpasswd -U will -j aghealth123

To lookup DNS info use dig
dig @64.219.249.164 gl.ddiglobal.com NS
or
dig gm.ddiglobal.com soa
or
dig @dns11.mot.com dl.ddiglobal.com a

Directory Size
du -sh
du -sk
du -m
du -k
du -b
du -cm
du -cmh
man du
wc -l

lists all IP addresses for that server
netstat -rn

df -k = list systems alloc. %
ls -l = list file size, & date

find / -name core -print = finds all core files
find / -xdev -size +1000000c -print = finds files more than 1 Meg in size

core = deletable temp files ( or cat /dev/null >(filname) )
/var/adm/messages = deletable message. files in this dir
/var/adm/last.log = reset back to zero for more room
/var/cron/log = was at 3 Meg lastime file system was full reset by ( cat /dev/null >log )
/var/adm/wtmp = reset back to zero by ( cat /dev/null >wtmp )
/var/adm/wtmpx = reset back to zero by ( cat /dev/null >wtmpx )

fsck = file system check( cannot be in openwindows )

Tape back up
pwd = shows where you are at
from /export/home/punchline/bin
tar cvf /dev/rst4 . = will back up fms

To setup linux routes (Cubes)
route add -net 192.168.100.0 gw 192.168.5.72 netmask 255.255.255.0

To UnTar
tar -zxvf ***********.tar.gz

To see which mail servers you have
which ipop3d
which imap

Change Owner of file or files
chown -Rv root *

Change group of file or files
chown -Rv .users *

See what ports are open.............
netstat --inet -an

Remove ^M in Linux
sed 's/.$//' infile.txt > outfile.txt

Find
grep -r 'pattern' /var/www/html

Determine kernel version
uname -a

Determine Disk Space Usage
df -h

Determine where that useage is...
du -h --max-depth=0 /home

Auto Start
cd /etc/init.d/rc.5
ls -s ../init.d/mysqld ./s99mysqld

Global replace text in vi

:%s/oldText/newText/g

FTP Automation PHP Code

Basicly this is a php page that can be ran from either a browser or as a cron job. The agftp.php page creates the objects, sets applicable variables, and calls the required functions. Each function is fully contained and functional on it's own. This allows you to comment out functions that are not required as to create an individule workflow for each client. The full workflow is as follows...

Connects to the ftp server.
Gets the directory listing and determines if there are any new files.
Gets the new files.
Archives the newly downloaded files on the ftp server.
Moves the newly downloaded files to their final location on the network.
Looks for new files to push to the ftp server.
Pushes those files to the server.
Archives the newly pushed files.
Closes the FTP connection.
Notifies via email of new files or any errors.

Functions also exist to output to log files in html, windows .txt, and unix .txt files, get the initial default file listing, print array diag info, and to compress and archive log files.

FYI, This is a work in progress and subject to major changes....

This is the main page that calls the functions......

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
agftp.php>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[code]
ftp_user_name = "username"; //FTP server username
$TEST->ftp_user_pass = "password"; //FTP server password
$TEST->ftp_dir = NULL; //Active directory on FTP server
$TEST->ftp_server = "ftp.somewhere.com"; //FTP Server address
$TEST->passivemode; //To turn passive mode on or off
$TEST->list_default_file; //Name of file containing the default directory listing
$TEST->movefileto = "/mnt/agdevftp/CLIENTS/mcs/"; //Directory to move files to after download is complete on the network
$TEST->archdir = "."; //Directory to move files to after download is complete on the FTP server
$TEST->push_from_dir = "/home/ftpusers/ftpalc/toclient/"; //Directory to push files from network to the FTP server
$TEST->push_to_dir = "IN"; //Directory to push files to on the FTP server
$TEST->push_arch_dir = "archive/"; //Directory pushed files are archived to this network directory
$TEST->output_type = "web"; //Determines which type of log is generated, log format or html format
$TEST->email_to1 = "will@aghealth123.com"; //Email to address
$TEST->email_to2 = "jonn@aghealth123.com"; //Email to address
$TEST->email_to3 = "jonn@aghealth123.com"; //Email to address
$TEST->email_to4 = "jonn@aghealth123.com"; //Email to address
$TEST->email_to5 = "jonn@aghealth123.com"; //Email to address
$TEST->email_subject = "MCS New File Notification"; //Email subject default
$TEST->email_from = "MCSAutomation@aghealth123.com"; //Email from default
$TEST->email_body = "Please view the attached logfile."; //Email body default
$TEST->email_pri = 4; //Email priority default
$TEST->logfile = "log/logfile"; //Log file name minus timestamp
$TEST->client = "ALC"; //Client Name

$TEST->agoutput("#####################################################################################");
$TEST->agoutput("TEST FTP PROCESS");
$TEST->agoutput("#####################################################################################");
$TEST->agftpconnect(); //Connect to the FTP Server
$TEST->agftpgetinitdefaultlist(); //Get the default initial list
$TEST->agftpgetnewlist(); //Get a list of new files
$TEST->agftpgetfiles(); //Get new files that are on the new file list
$TEST->agftparchfiles(); //Archive files on the FTP server. Rename/Move
$TEST->agftpmovefiles(); //Moves the downloaded files to their final location on the network
$TEST->agpushlist(); //Gathers a list of files to PUSH to the FTP Server
$TEST->agpushtoftp(); //Uploads the files on the push_dir_list to the FTP server
$TEST->agpusharchfiles(); //Archive files on the network server. Rename/Move
$TEST->agftpclose(); //Close the connection to the FTP Server
$TEST->agmailnotify(); //Emails notification of new file
$TEST->printinfo(); //Prints array info for diag purposes
*/

///////////////////////// MCS Account Setup /////////////////////////
$MCS = new AGFTP;
$MCS->ftp_user_name = "username"; //FTP server username
$MCS->ftp_user_pass = "password"; //FTP server password
$MCS->ftp_dir = NULL; //Active directory on FTP server
$MCS->ftp_server = "ftp.somewhere.com"; //FTP Server address
// $MCS->passivemode; //To turn passive mode on or off
// $MCS->list_default_file; //Name of file containing the default directory listing
$MCS->movefileto = "/mnt/agdevftp/CLIENTS/mcs/"; //Directory to move files to after download is complete on the network
$MCS->archdir = "."; //Directory to move files to after download is complete on the FTP server
// $MCS->push_from_dir = "/home/ftpusers/ftpalc/toclient/"; //Directory to push files from network to the FTP server
$MCS->push_to_dir = "IN"; //Directory to push files to on the FTP server
$MCS->output_type = "web"; //Determines which type of log is generated, log format or html format
$MCS->email_to1 = "will@aghealth123.com"; //Email to address
$MCS->email_to2 = "jonn@aghealth123.com"; //Email to address
$MCS->email_to3 = "scottv@aghealth123.com"; //Email to address
// $MCS->email_to4 = "jonn@aghealth123.com"; //Email to address
// $MCS->email_to5 = "jonn@aghealth123.com"; //Email to address
$MCS->email_subject = "MCS New File Notification"; //Email subject default
$MCS->email_from = "MCSAutomation@aghealth123.com"; //Email from default
$MCS->email_body = "Please view the attached logfile."; //Email body default
// $MCS->email_pri = 4; //Email priority default
$MCS->logfile = "log/mcslogfile"; //Log file name minus timestamp
$MCS->client = "MCS"; //Client Name

$MCS->agoutput("#####################################################################################");
$MCS->agoutput("MCS FTP PROCESS");
$MCS->agoutput("#####################################################################################");
$MCS->agftpconnect(); //Connect to the FTP Server
// $MCS->agftpgetinitdefaultlist(); //Get the default initial list
$MCS->agftpgetnewlist(); //Get a list of new files
$MCS->agftpgetfiles(); //Get new files that are on the new file list
// $MCS->agftparchfiles(); //Archive files on the FTP server. Rename/Move
$MCS->agftpmovefiles(); //Moves the downloaded files to their final location on the network
// $MCS->agpushlist(); //Gathers a list of files to PUSH to the FTP Server
// $MCS->agpushtoftp(); //Uploads the files on the push_dir_list to the FTP server
$MCS->agpusharchfiles(); //Archive files on the network server. Rename/Move
$MCS->agftpclose(); //Close the connection to the FTP Server
$MCS->agmailnotify(); //Emails notification of new file
$MCS->printinfo(); //Prints array info for diag purposes

///////////////////////// ALC Account Setup /////////////////////////
$ALC = new AGFTP;
$ALC->ftp_user_name = "username"; //FTP server username
$ALC->ftp_user_pass = "password"; //FTP server password
$ALC->ftp_dir = "OUT"; //Active directory on FTP server
$ALC->ftp_server = "ftp.somewhere.com"; //FTP Server address
// $ALC->passivemode; //To turn passive mode on or off
// $ALC->list_default_file; //Name of file containing the default directory listing
$ALC->movefileto = "/mnt/ftpalc/fromclient/"; //Directory to move files to after download is complete on the network
$ALC->archdir = "Archive"; //Directory to move files to after download is complete on the FTP server
$ALC->push_from_dir = "/mnt/ftpalc/toclient/"; //Directory to push files from network to the FTP server
$ALC->push_to_dir = "IN"; //Directory to push files to on the FTP server
$ALC->output_type = "web"; //Determines which type of log is generated, log format or html format
$ALC->email_to1 = "will@aghealth123.com"; //Email to address
$ALC->email_to2 = "jonn@aghealth123.com"; //Email to address
$ALC->email_to3 = "scottv@aghealth123.com"; //Email to address
// $ALC->email_to4 = "jonn@aghealth123.com"; //Email to address
// $ALC->email_to5 = "jonn@aghealth123.com"; //Email to address
$ALC->email_subject = "ALC New File Notification"; //Email subject default
$ALC->email_from = "ALCAutomation@aghealth123.com"; //Email from default
$ALC->email_body = "Please view the attached logfile."; //Email body default
// $ALC->email_pri = 4; //Email priority default
$ALC->logfile = "log/alclogfile"; //Log file name minus timestamp
$ALC->client = "ALC"; //Client Name

$ALC->agoutput("#####################################################################################");
$ALC->agoutput("ALC FTP PROCESS");
$ALC->agoutput("#####################################################################################");
$ALC->agftpconnect(); //Connect to the FTP Server
// $ALC->agftpgetinitdefaultlist(); //Get the default initial list
$ALC->agftpgetnewlist(); //Get a list of new files
$ALC->agftpgetfiles(); //Get new files that are on the new file list
$ALC->agftparchfiles("alc"); //Archive files on the FTP server. Rename/Move
$ALC->agftpmovefiles(); //Moves the downloaded files to their final location on the network
$ALC->agpushlist(); //Gathers a list of files to PUSH to the FTP Server
$ALC->agpushtoftp(); //Uploads the files on the push_dir_list to the FTP server
$ALC->agpusharchfiles(); //Archive files on the network server. Rename/Move
$ALC->agftpclose(); //Close the connection to the FTP Server
$ALC->agmailnotify(); //Emails notification of new file
$ALC->printinfo(); //Prints array info for diag purposes

?>[/code]

this is the included function code used by the main program.

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
ftpfunction.php >>>>>>>>>>>>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

[code]
output_type == "web") {
$filename = $this->logfile . date("YmdHis") . ".html";
} else {
$filename = $this->logfile . date("YmdHis") . ".txt";
}

if ($this->logfile_whole) {
$filename = $this->logfile_whole;
} else {
$this->logfile_whole = $filename;
}

if (!$handle = fopen($filename, 'a')) {
$this->errorflag = true;
echo "Cannot open file ($filename).";
$this->email_body = $this->email_body . " Error: Cannot open file ($filename).";
return;
}
if ($this->output_type == "log") {
if ($nobreak) {
if (fwrite($handle, $output_string) === false) {
$this->errorflag = true;
echo "Cannot write to file ($filename).";
$this->email_body = $this->email_body . " Error: Cannot write to file ($filename).";
return;
}
printf("%s", $output_string);
} else {
if (fwrite($handle, $output_string . "\n") === false) {
$this->errorflag = true;
echo "Cannot write to file ($filename).";
$this->email_body = $this->email_body . " Error: Cannot write to file ($filename).";
return;
}
printf("%s \n", $output_string);
}
}
if ($this->output_type == "web") {
if ($nobreak) {
if (fwrite($handle, $output_string) === false) {
$this->errorflag = true;
echo "Cannot write to file ($filename).";
$this->email_body = $this->email_body . " Error: Cannot write to file ($filename).";
return;
}
printf("%s", $output_string);
} else {
if (fwrite($handle, $output_string . "
") === false) {
$this->errorflag = true;
echo "Cannot write to file ($filename).";
$this->email_body = $this->email_body . " Error: Cannot write to file ($filename).";
return;
}
printf("%s
", $output_string);
}
}
if ($this->output_type != "web" AND $this->output_type != "log") {
$this->errorflag = true;
echo "OUTPUT TYPE UNKNOWN";
$this->email_body = $this->email_body . " Error: Log file output type unknown.";
return;
}

fclose($handle);
}

//*********************************************************************************************************************
// AGFTPCONNECT Connects to the FTP server
//*********************************************************************************************************************
function agftpconnect() {
$this->agoutput("*************agftpconnect fuction started***************");
if (($this->conn_id = ftp_connect($this->ftp_server)) == false) {
$this->errorflag = true;
$this->abort = true;
$this->email_body = $this->email_body . " Error: Failed to connect to FTP server.";
}
if (($this->login_result = ftp_login($this->conn_id, $this->ftp_user_name, $this->ftp_user_pass)) == false){
$this->errorflag = true;
$this->abort = true;
$this->email_body = $this->email_body . " Error: Failed to login to FTP server.";
}
if ((!$this->conn_id) || (!$this->login_result)) {
$this->errorflag = true;
$this->abort = true;
$this->agoutput("FTP connection has failed!");
$this->agoutput("Attempted to connect to $this->ftp_server for user $this->ftp_user_name.");
$this->email_body = $this->email_body . " Error: Attempted to connect to $this->ftp_server for user $this->ftp_user_name.";
return;
} else {
$this->agoutput("Connected to $this->ftp_server, for user $this->ftp_user_name.");
}
if ($this->passivemode == "true") {
if (ftp_pasv($this->conn_id, true)) {
$this->agoutput("Passive set to true.");
} else {
$this->errorflag = true;
$this->abort = true;
$this->agoutput("Passive failed to set to true.");
$this->email_body = $this->email_body . " Error: Passive failed to set to true.";
}
}
if ($this->passivemode == "false") {
if (ftp_pasv($this->conn_id, "false")) {
$this->agoutput("Passive set to false.");
} else {
$this->errorflag = true;
$this->abort = true;
$this->agoutput("Passive failed to set to false.");
$this->email_body = $this->email_body . " Error: Passive failed to set to false.";
}
}
$this->agoutput();
return $this->login_result;
}

//*********************************************************************************************************************
// AGFTPGETNEWLIST Retreives dir list from server, compares to default list and returns list of new files.
//*********************************************************************************************************************
function agftpgetnewlist(){
$this->agoutput("*************agftpgetnewlist fuction started************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if ($this->ftp_dir){
if (ftp_chdir($this->conn_id, $this->ftp_dir)){
$this->agoutput("Changed dir to $this->ftp_dir.");
} else {
$this->errorflag = true;
$this->agoutput("Failed to change to dir $this->ftp_dir.");
$this->email_body = $this->email_body . " Error: Failed to change to dir $this->ftp_dir.";
return;
}
}
if (!$this->current_dir = ftp_nlist($this->conn_id, "")) {
$this->current_dir = NULL;
$this->newfile = NULL;
$this->agoutput("NO new files found.");
} else {
$this->agoutput("Current directory listing retrieved.");
}

// gets default listing into array
if (!$this->list_default_file) $this->list_default_file=$this->ftp_server . ".txt";
$this->opened_default_file=file($this->list_default_file);
$this->default_file_lines = count($this->opened_default_file);
$this->arraycount = 0;
while ($i = each($this->opened_default_file)){
$this->default_file_array[$this->arraycount] = $i['value'];
//strips leading and trailing spaces out
$this->default_file_array[$this->arraycount] = trim($this->default_file_array[$this->arraycount]);
$this->arraycount++;
}

// check the array differeces
if ($this->current_dir) {
$this->result = array_diff($this->current_dir, $this->default_file_array);
}
if (count($this->result) != 0) {
$this->email_body = $this->email_body . " New inbound files found.";
$this->newfile = true;
}
// $array = array();
// $array[0] = "\n";
// $result = array_diff($result,$array);
$this->agoutput();

}

////Error check improvement stop here

//*********************************************************************************************************************
// AGFTPGETFILES Downloads the files on the new file list
//*********************************************************************************************************************
function agftpgetfiles(){
$this->agoutput("*************agftpgetfiles fuction started**************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if (!$this->newfile) {
$this->agoutput("NO new files found.");
$this->agoutput();
return;
}
reset($this->result);
foreach($this->result as $this->file) {
$this->agoutput("This is the file attempting to get... $this->file.");
if (ftp_get($this->conn_id, $this->file, $this->file, FTP_BINARY)) {
$this->agoutput("Successfully written to $this->file.");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem with $this->file.");
}
}
$this->agoutput();
}

//*********************************************************************************************************************
// PRINTINFO Prints array info for diag purposes.
//*********************************************************************************************************************
function printinfo(){
$this->agoutput("*************printinfo fuction started******************");
$this->agoutput("Current Dir .............", true);
var_dump($this->current_dir);
$this->agoutput();
$this->agoutput("Default Dir .............", true);
var_dump($this->default_file_array);
$this->agoutput();
$this->agoutput("Differences Dir .........", true);
var_dump($this->result);
$this->agoutput();
$this->agoutput("Push Dir ................", true);
var_dump($this->push_dir_list);
$this->agoutput();
}

//*********************************************************************************************************************
// AGFTPCLOSE Closes the FTP connection
//*********************************************************************************************************************
function agftpclose(){
$this->agoutput("*************agftpclose fuction started*****************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
ftp_close($this->conn_id);
$this->agoutput("FTP Connection closed.");
$this->agoutput();
}

//*********************************************************************************************************************
// AGFTPMOVEFILES Moves the downloaded files to their final location on the network.
//*********************************************************************************************************************
function agftpmovefiles() {
$this->agoutput("*************agftpmovefiles fuction started*************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if ($this->newfile) {
reset($this->result);
foreach($this->result as $this->file) {
$this->agoutput(" This is the file attempting to move... $this->file.");
if (rename($this->file, $this->movefileto . $this->file)) {
$this->agoutput("Successfully moved to $this->movefileto.");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem with $this->file.");
}
if ($this->movfileto2) {
if (rename($this->file, $this->movfileto2 . $this->file)) {
$this->agoutput("Successfully moved to $this->movefileto.");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem with $this->file.");
}
}
}
} else {
$this->agoutput("NO new files to move.");
}
$this->agoutput();
}

//*********************************************************************************************************************
// AGFTPGETINITDEFAULTLIST Retrieves the inital directory listing to use as default
//*********************************************************************************************************************
function agftpgetinitdefaultlist(){
$this->agoutput("*************agftpgetinitdefaultlist fuction started********");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if ($this->ftp_dir){
if (ftp_chdir($this->conn_id, $this->ftp_dir)){
$this->agoutput("Changed dir to $this->ftp_dir.");
} else {
$this->errorflag = true;
$this->agoutput("Failed to change to dir $this->ftp_dir.");
return;
}
}
// List current direcoty
$this->current_dir = ftp_nlist($this->conn_id, ".");
reset ($this->current_dir);
if (file_exists($this->ftp_server . ".txt")) {
unlink($this->ftp_server . ".txt");
$this->agoutput("Deleting file $this->ftp_server.txt.");
}

if (!$this->handle = fopen($this->ftp_server . ".txt", 'a')) {
$this->errorflag = true;
$this->agoutput("Cannot open file ($this->ftp_server.txt)");
return;
}
foreach($this->current_dir as $this->file) {
if (fwrite($this->handle, $this->file . "\n") === false) {
$this->errorflag = true;
$this->agoutput("Cannot write to file ($this->ftp_server.txt)");
return;
}
$this->agoutput("Success, wrote ($this->file) to file ($this->ftp_server.txt) ");
}
fclose($this->handle);
$this->agoutput();
}

//*********************************************************************************************************************
// AGFTPARCHFILES Moves on the FTP server downloaded files to the FTP archive directory.
//*********************************************************************************************************************
function agftparchfiles($client = NULL) {

if ($client == "alc") {
$this->agoutput("*************agftparchfiles fuction started*************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
reset($this->result);
foreach($this->result as $this->file) {
$this->agoutput(" This is the file attempting to archive... $this->file.");
if (ftp_put($this->conn_id, $this->archdir . "/" . $this->file, $this->file, FTP_BINARY)) {
$this->agoutput("Successfully moved file $this->file to $this->archdir.");
if (ftp_delete($this->conn_id, $this->file)) {
$this->agoutput("Successfully deleted orginal file");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem archiving $this->file.");
}
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem archiving $this->file.");
}
}
if(count($this->result) == 0) $this->agoutput("NO files were archived");
$this->agoutput();
} else {
$this->agoutput("*************agftparchfiles fuction started************");
reset($this->result);
foreach($this->result as $this->file) {
$this->agoutput(" This is the file attempting to archive... $this->file.");
if (ftp_rename($this->conn_id, $this->file, $this->archdir . $this->file)) {
$this->agoutput("Successfully moved file $this->file to $this->archdir.");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem archiving $this->file.");
}
}
if(count($this->result) == 0) $this->agoutput("NO files were archived");
$this->agoutput();
}
}

//*********************************************************************************************************************
// AGPUSHLIST Gathers a list of files to PUSH to the FTP Server.
//*********************************************************************************************************************
function agpushlist() {
$this->agoutput("*************agpushlist fuction started*****************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if ($this->handle = opendir($this->push_from_dir)) {
$this->arraycount = 0;
while (false !== ($this->file = readdir($this->handle))) {
// if ($this->file !== "." && $this->file !== ".." && strrchr($this->file, ".") == ".pgp") {
if ($this->file !== "." && $this->file !== ".." && strcasecmp(strrchr($this->file, "."), ".pgp") == 0) {
$this->push_dir_list[$this->arraycount] = $this->file;
$this->newfile_push = true;
$this->email_body = $this->email_body . " NEW outbout files found.";
$this->arraycount++;
}
}
closedir($this->handle);

}
if (!$this->newfile_push) {
$this->agoutput("NO outbound files found.");
} else {
$this->agoutput("NEW outbound files found.");
}
$this->agoutput();
}

//*********************************************************************************************************************
// AGPUSHTOFTP Uploads the files on the push_dir_list to the FTP server.
//*********************************************************************************************************************
function agpushtoftp(){
$this->agoutput("*************agpushtoftp fuction started****************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if (!$this->newfile_push) {
$this->agoutput("NO new files found.");
$this->agoutput();
return;
}

if ($this->push_to_dir){
echo "Current directory: " . ftp_pwd($this->conn_id) . "\n";
ftp_chdir($this->conn_id, "..");
if (ftp_chdir($this->conn_id, $this->push_to_dir)){
$this->agoutput("Changed dir to $this->push_to_dir.");
} else {
$this->errorflag = true;
$this->agoutput("Failed to change to dir $this->push_to_dir.");
return;
}
}

reset($this->push_dir_list);
foreach($this->push_dir_list as $this->file) {
$this->agoutput("This is the file attempting to push... $this->file.");
if (ftp_put($this->conn_id, $this->file, $this->push_from_dir . $this->file, FTP_BINARY)) {
$this->agoutput("Successfully pushed to $this->file.");
} else {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem with $this->file.");
}
}
$this->agoutput();

}

//*********************************************************************************************************************
// AGPUSHTARCHFILES Archive files on the network server. Rename/Move
//*********************************************************************************************************************
function agpusharchfiles(){
$this->agoutput("*************agpusharchfiles fuction started************");
if ($this->abort == true){
$this->agoutput("Function Aborted");
return;
}
if($this->newfile_push) {
reset($this->push_dir_list);
foreach($this->push_dir_list as $this->file) {
if(!rename($this->push_from_dir . $this->file, $this->push_from_dir . $this->push_arch_dir . $this->file)) {
$this->errorflag = true;
$this->agoutput("Oopps, There was a problem archiving $this->file.");
} else {
$this->agoutput("$this->file archived normally.");
}
}
} else {
$this->agoutput("NO files to archive.");
}
$this->agoutput();
return;
}

", $m->Get(), "







//*********************************************************************************************************************
// AGCOMPRESSLOGS Gathers a list of files to PUSH to the FTP Server.
//*********************************************************************************************************************
function agcompresslogs() {
$this->agoutput("*************agcompresslogs fuction started*****************");
if ($this->handle = opendir("log/")) {
$this->arraycount = 0;
while (false !== ($this->file = readdir($this->handle))) {
// if ($this->file !== "." && $this->file !== ".." && strrchr($this->file, ".") == ".pgp") {
if ($this->file !== "." && $this->file !== ".." && $this->file !== "archive") {
$this->logfile_list[$this->arraycount] = "log/" . $this->file;
$this->arraycount++;
}
}
closedir($this->handle);
}

include("tar.php");
$filename = "archive/archive" . date("YmdHis") . ".tar.gz";
$tar_object = new Archive_Tar($filename, true);
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
$tar_object->createModify($this->logfile_list, "");
reset($this->logfile_list);
sleep(15);
foreach($this->logfile_list as $this->file) {
if(!unlink($this->file)) {
$this->agoutput("A problem was encountered attempting to delete $this->file.");
} else {
// $this->agoutput("$this->file archived normally.");
}
}

$this->agoutput("Logfile Dir ................", true);
var_dump($this->logfile_list);

$this->agoutput("Compress function complete.");
$this->agoutput();
}

}
?>
[/code]

Suse 9.0 and AD: How To

Suse 9.0 Window Active Directory / Domain How-to:

Purpose: This document will guide the setup of Suse 9.0 to support unified login as well as file and directory permission compatibility with in a Microsoft windows domain or active directory environment.

Software and disclaimer:
This document was intended for Suse Linux 9.0 running samba-2.2.8a-107 only. Though there are common settings that can carry over to other Linux distributions this is what this document was written for. The pam structure differs the most between different Linux distribution's, documentation for redHat and Mandrake can be found on the web. Since this document was written the hard way through trial and error using bits and pieces of documentation found through books and on the web it may have faults that I am unaware of.

Packages used in the creation of this document:
pam_smb-1.1.6-528
samba-2.2.8a-107

Windows Structure:

Below I will define a fictional network, the network will consist of two machines the first listed is the domain controller running windows and the second machine will be our Linux workstation the domain name is also listed. The domain controller will also serve as the password server for the domain. Before you get started be aware that you must have a domain administrator account to put your Linux client in the domain.

Windows Side:
DomainMaster.MyCompany.com
Domain Name: MyCompany.com

Linux Side:
my-linux.MyCompany.com

DNS:
Before you get to far make sure that you have DNS name resolution to your domain controller from your Linux client, you should be able to ping it using the full domain name. (Note do not try to ping it by short name Linux is not using wins). If you cannot ping it then add the name to your hosts file located in the /etc directory.

Samba Configuration files:

1.From the console login as root using the su command.

Example:

# su

2.Change to the /etc/samba directory and make a backup of your smb.conf file.

Example:

# cp smb.conf smb.org
3.Edit the smb.conf global section, the following example uses MYCOMPANY as the domain and the domain controller is DomainMaster.MYCOMPANY.com. Substitute to suit your own network. Most of these lines will already be in your smb.conf file for the items that are not add them, for the lines that are different, change them. (note, you can add more then one password server just leave a space between the entries.)

[global]
workgroup = MYCOMPANY
os level = 2
time server = Yes
unix extensions = Yes
encrypt passwords = Yes
map to guest = Bad User
printing = CUPS
printcap name = CUPS
password server = DomainMaster.MYCOMPANY.com
socket options = SO_KEEPALIVE IPTOS_LOWDELAY TCP_NODELAY
wins support = No
veto files = /*.eml/*.nwd/riched20.dll/*.{*}/
security = domain
netbios name = my-Linux

4.Next we will setup the winbind section of the file , add these parms after the global section.

#winbind options per rmgl 03-02-04:

winbind separator = +
winbind uid = 10000-20000
winbind gid = 10000-20000
winbind cache time = 15
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%D/%U
template shell = /bin/bash

#Allow password changing from Windows to update Linux System Password:
unix password sync = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *New*password* %n\n *Retype*new*password* %n\n *password:*all*authentication*tokens*updated*succe ssfully

#Use PAM's password change control flag for Samba. If enables,
#then PAM will be used for password changes when requested by
#an SMB client instead of the program listed in the passwd program.
#It should be possible to enable this without changing your passwd
#chat parameter for most setups.

Pam password change = yes

5.Save the smb.conf file and close it, next run the testparm command to test the smb.conf file for syntax errors. If you have errors go back and fix them and then re-run testparm.

Example:

# testparm smb.conf

NSSWICH configuration:

1.Backup your nsswitch.conf file (note that I use the .org which stands for original, I will go back later and make copies of the working files as .bak)

Example:
# cp nsswitch.conf nsswitch.org

2.After your nsswitch.conf open it and add winbind to the end of the passwd: and group: lines at the beginning of the line. Then save and close the file when you are finished.

Example:

passwd: compat winbind
group: compat winbind

3.After you are finished editing the nsswitch.conf file run ldconfig to activate the changes.

Example:
# /sbin/ldconfig

Samba Service:

From the console cd over to the etc/rc.d directory , this is where you can view , change or modify your systems services, in the next few steps we will setup these services to ensure they start every time and then we will also start them.

1.From the console use the chkconfig script to see if smb and winbind services are on. We are looking for these services to be on for runlevels 3 and 5.

Example:
# chkconfig --list smb

2.If the services are not already set to on for runlevels 3 and 5 turn them on using the chkconfig

Example: (turn on smb and winbind:)
# chkconfig smb on
# chkconfig winbind on

3. Next we will have to disable the nscd service which interferes with the proper functioning of winbind.

Example:
#chkconfig nscd off

4. Now turn off the nscd service:

Example:
#./nscd stop

5.We are now ready to start smb and winbind, if it is running already restart them:
Example: (note that the two lines are separate commands)
Example:
#./smb start
#./winbind start

Join the Domain:

Joining the domain requires that you have name resolution to your password server (PDC) and an administrative account that can move machines into the domain. We will first create the domain account and then we will test winbind and local system accounts and groups to ensure they are both pulling the correct information.

1.From the console as root join the domain the syntax format is explained below:
DOMAIN = the name of your domain (upper case)
PDC = Full name of your PDC server ServerName.Domain.com
user_name = The domain username with admin privileges

Example:

# smbpasswd -j DOMAIN -r PDC -U user_name

2.We will now test winbind to ensure we can pull user and group into from the domain. Users should show up as DOMAIN+USER when the results are returned.

Example: (get users)
# wbinfo -u

Example: (get groups)
# wbinfo -g

Example: (tests connection)
# wbinfo -t
3. Next test the Linux system password, by changing the nsswitch.conf file the system should now see domain resources along with the local Linux machine accounts (note sometimes this command takes a long time to return)

Example: (list of users)
# getent passwd

Example: (list groups)
#getent group

PAM configuration:

(WARNING!!! DO EDIT ANY PAM FILES BEFORE BACKING THEM UP, DO NOT REBOOT UNTIL YOU HAVE TESTED YOUR CHANGES, NOT DOING SO CAN LOCK YOU OUT OF YOUR SYSTEM!!!!)

Were almost finished, the pam configuration is the last major component to configure. In this section we will setup the pam files to allow login to the system and we will also setup the base home directory. It would be wise to create a boot disk at this point, the installation CD can also serve as a point of rescue as well just make note of your hard devices listed in your fstab file, trying to find this info later can be hard if you are locked out of your system.

1.The first step will be to backup the pam files we will be working with, in this document there are only three files that will be edited. The pam files are stored in the etc/pam.d , you should be logged on as root, backup the following files, login, samba, and xdm

Example:
# cp login login.org
#cp samba samba.org
#cp xdm xdm.org

2.Edit the login file to add your winbind info below is an example of the file I created, remember the order of the lines matters, pam reads the file from the top down allowing you to go on to the next line only if the credentials supplied are good to pass the current line. Lines using pam_winbind.so and pam_mkhomedir.so were added.

#%PAM-1.0
auth required pam_securetty.so
auth required pam_env.so
auth sufficient pam_unix2.so nullok
auth sufficient pam_winbind.so use_first_pass
auth required pam_deny.so
auth required pam_nologin.so
account sufficient pam_winbind.so
account required pam_unix2.so
password required pam_pwcheck.so nullok
password required pam_unix2.so nullok use_first_pass use_authtok
session required pam_mkhomedir.so skel=/etc/skel/ umask=0022
session sufficient pam_unix2.so none # debug or trace
session sufficient pam_limits.so

3. Edit the xdm file and add the pam_winbind.so parameters below is an example of my file.

#%PAM-1.0
auth sufficient pam_winbind.so
auth sufficient pam_unix2.so use_first_pass nullok #set_secrpc
account sufficient pam_winbind.so
account required pam_unix2.so
password required pam_unix2.so #strict=false
session required pam_unix2.so debug # trace or none
session required pam_devperm.so
session required pam_resmgr.so

4.Next edit the samba file and ensure it looks like the following example below.

#%PAM-1.0
auth required pam_unix.so
account required pam_unix.so

Create domain home root directory:

Remember in the samba file we specified, template homedir = /home/%D/%U this means that we will have to create the %D (domain) directory and the %U (user) will be created automatically when the user logs on.

Example: (change MyDomain to the name of your domain.)

# cd /home
# mkdir MyDomain
# chmod 777 MyDomain

So now when a user logs in MyDomain+FRED the samba script will put the user in /home/MyDomain/ and will automatically create FRED's home directory.

Testing PAM Settings:

The following steps are required before you move on if you are not able to perform all the steps below you must correct your pam configuration files so you can. If you get stuck on any of the steps ensure you do not reboot your machine without restoring your original pam files.

Console Login Test:

1.Using Ctrl+ALT+F1 start a new console session we will use this as a back door for testing our PAM setting. At the login prompt test your login using the local root account.

2.After you have verified that you can login using the machines local accounts you can test a console login of a domain account, the username is specified as DOMAIN+USER.

X-windows Login Test:
If you successfully managed to login using both the local root account and a domain account the next step is to test X-windows.

1.From the same console session that you performed the previous tests login as root.

2.Using Ctrl+ALT+F1 change back to your windows session

3.Logout of the X-windows session and return to the login window. (note this will take a long time because the login will pull all the domain accounts to add to the list, don't worry about this now we will change the settings later)
4.Test the login using a local machine account then logout after login is compete.

5.Test domain login using username specified as
DOMAIN+USER

If all tests were good congratulation's, if your still "work in process" you can save your pam files with the work you have done to this point but remember to restore your originals if you intend to reboot.

X-window login box:

As you seen during the test, our login box pulled all the account names that exist on the domain, this should be fine for a small user base. If you have a large user base and do not wish to display all the user names you can disable this option from within yast2 under system administration ==> login manager , select the users tab and change the show users to "none" .

Changing File and folder ownership from the console:

Changing ownership of files and folders isn't to different from what you would normally do from a console only now you have to specify the user using the domain scheme of DOMAIN+USER, below is an example.

Example:
# chown DOMAIN+USER filename

Part II Server Setup in a Domain Environment:

After you have completed the client install and verified everything is working you can setup the server side. The goal is to setup your Linux machine to support the identical scheme for directories and file permissions and shares as a Microsoft server would. To do this your linux machine must have the following configuration or software installed.

-ACL kernel support (using ext2 or ext3 "rieser filesystem"), by default Suse 9 has this option enabled in the kernel. The ACL option will have to be enabled though on the volume you wish to export your Samba shares.

-The above client setup must be enabled in order for Samba to successfully use the domain as a back end for file and folder permissions.

-If not already installed install the acl tools package to allow acl manipulation and querying from the linux side, at the time of this document the current package is acl-2.2.15-23

ALC support:

By default ACL support is already built into the Suse 9.X kernel , as long as your using a filesystem that supports ACL we are in good shape (ext2 and ext3). To enable ACL we will simply edit our /etc/fstab file and add the ACL option to the mount command of the volume where we will be exporting our Samba shares.

1.Using the console login as root using the su command, cd to the /etc directory and make a backup of your fstab file.

Example:
# cp fstab fstab.bak

2.Next edit your fstab and add the acl option towards the end of the file.

Example:

Before: /def/hda1 / reiserfs defaults, 1 1
After: /def/hda1 / reiserfs defaults,acl 1 1

3.Save the fstab file and reboot the machine, if you have any problems it more then likely you using a filesystem that does not support ACL.

Samba Configuration:

The samba configuration will take place in two parts, we will first setup our shares on the the linux side and then we will change ownership of the shares to our Microsoft domain accounts from there to setup permissions and access to the shares. You can later adjust the default permission and creation modes on the samba side if you don't like how I have them here but for the sake of sanity use the default setting I use first.

1.Create the directories you would like to use for your Samba exports, after you have created them run a chmod and then chown to your domain account you will be using later to setup the permissions on the domain side.
Example:
# mkdir workgroup-files
# chmod 770 workgroup-files
#chown -R DOMAIN+USER workgroup-files

2.Next create a backup of your working smb.conf file then edit it. For your shares using the following format, repeat the format for each share you wish to export.

Example Share:

[share]
comment = share
path = /home/share
fstype = NTFS
browseable = Yes
writeable = Yes
acl support = Yes
security mask = 0750
directory mask = 0750
force security mode = 0750
force directory security mode = 0750
directory security mask = 0750

3. After you have setup your shares save the smb.conf file and restart both your smb and winbind services located in /etc/rc.d directory.

Example:
# ./smb restart
#./winbind restart

4. From your windows machine (WINNT, WIN2K , or XP) map to your shares using the account you gave ownership to on the Linux side. Once your mapped you can right click on the share itself to define the share defaults for file creation and default permissions. Individual folders can be manipulated as you would normally. Use a few accounts to connect as different users to test your stetting and ensure it works as you intend it to.

ACL from the Linux Side:

A standard ls or dir command will not show you the ACL info from the linux side , you can use the getfacl and the setfacl command to query or manipulate ACL information from the console.

Example:
# getfacl DirectoryName

FTP Monitor/Decrypt/Transfer

Below is a set of scripts that I use to monitor an FTP site, when something is found uploaded it downoads the file, moves the orginal to archive, decrypts the pgp , moves the files to their final resting places, and emails me with a notification.


ccg

./control > ccgtransaction`date '+%Y%m%d'`.log

mv ccgtransaction* /mnt/agdevftp/CLIENTS/comprehensive/fromCLIENT/Archive/Log/


control

#mount -t smbfs -o username=will,password=passwdhere //agit/support /mnt/network

#umount /mnt/network


./listfiles

if diff --brief list list.default

then

set new "no"

echo "`date` No new files." >> log

else

echo "New File" > newfile

echo "`date` New files present." >> log

while read file

do

if [[ $file == archive* ]]

then

echo "`date` $file was found to be archived"

else

echo "`date` $file" >> log

./ftpget $file

./ftprename $file

fi

done
cd files

./../decryptcntl *

cd ..

./movefiles

fi


if [ -f newfile ]

then

php mail.php

rm -f newfile

fi


decryptcntl

./../decryptpgp $1

./../decryptpgp $2

./../decryptpgp $3

./../decryptpgp $4

./../decryptpgp $5

./../decryptpgp $6

./../decryptpgp $7

./../decryptpgp $8

./../decryptpgp $9

./../decryptpgp $10


decryptpgp

#!/usr/bin/expect -f


set force_conservative 0 ;# set to 1 to force conservative mode even if

;# script wasn't run conservatively originally

if {$force_conservative} {

set send_slow {1 .1}

proc send {ignore arg} {

sleep .1

exp_send -s -- $arg

}

}


set timeout -1


set arg1 [lindex $argv 0]

set arg2 [lindex $argv 1]


cd /root/ftp/files


spawn gpg --decrypt-files $arg1

match_max 100000

expect "Enter passphrase: "

send "pgppasshere\r"

send "\r\r"

expect eof


ftpclear

#!/usr/bin/expect -f


set force_conservative 0 ;# set to 1 to force conservative mode even if

;# script wasn't run conservatively originally

if {$force_conservative} {

set send_slow {1 .1}

proc send {ignore arg} {

sleep .1

exp_send -s -- $arg

}

}


set timeout -1

spawn ftp ftp.eedi.net

match_max 100000

expect "Name (ftp.eedi.net:root): "

send -- "userhere\r"

expect "Password:"

send -- "passwdhere\r"

expect "ftp> "

send -- "cd inbox\r"

expect "ftp> "

send -- "prompt\r"

expect "ftp> "

send -- "lcd files\r"

expect "ftp> "

send -- "mdelete *\r"

expect "ftp> "

send -- "bye\r"

expect eof


ftpget

#!/usr/bin/expect -f


set force_conservative 0 ;# set to 1 to force conservative mode even if

;# script wasn't run conservatively originally

if {$force_conservative} {

set send_slow {1 .1}

proc send {ignore arg} {

sleep .1

exp_send -s -- $arg

}

}


set arg1 [lindex $argv 0]


set timeout -1

spawn ftp ftp.eedi.net

match_max 100000

expect "Name (ftp.eedi.net:root): "

send -- "userhere\r"

expect "Password:"

send -- "passwdhere\r"

expect "ftp> "

send -- "cd inbox\r"

expect "ftp> "

send -- "prompt\r"

expect "ftp> "

send -- "lcd files\r"

expect "ftp> "

send -- "mget $arg1\r"

expect "ftp> "

send -- "bye\r"

expect eof


ftprename

#!/usr/bin/expect -f


set force_conservative 0 ;# set to 1 to force conservative mode even if

;# script wasn't run conservatively originally

if {$force_conservative} {

set send_slow {1 .1}

proc send {ignore arg} {

sleep .1

exp_send -s -- $arg

}

}


set arg1 [lindex $argv 0]

#set arg2 [lindex $argv 1]

set arg2 "archive/$arg1"


set timeout -1

spawn ftp ftp.eedi.net

match_max 100000

expect "Name (ftp.eedi.net:root): "

send -- "userhere\r"

expect "Password:"

send -- "passwdhere\r"

expect "ftp> "

send -- "cd inbox\r"

expect "ftp> "

send -- "rename $arg1\r"

expect "(to-name) "

send "$arg2\r"

expect "ftp> "

send -- "bye\r"

expect eof


listfiles

#!/usr/bin/expect -f


set force_conservative 0 ;# set to 1 to force conservative mode even if

;# script wasn't run conservatively originally

if {$force_conservative} {

set send_slow {1 .1}

proc send {ignore arg} {

sleep .1

exp_send -s -- $arg

}

}


set timeout -1

spawn ftp ftp.eedi.net

match_max 100000

expect "Name (ftp.eedi.net:root): "

send -- "userhere\r"

expect "Password:"

send -- "passwdhere\r"

expect "ftp> "

send -- "cd inbox\r"

expect "ftp> "

send -- "prompt\r"

expect "ftp> "

send -- "mls - list\r"

expect "ftp> "

send -- "bye\r"

expect eof


mail.php


mail("will@aghealth123.com,jonn@aghealth123.com","CCG Activity","CCG Activity has been detected\nAll files should have been transfered and inital processing completed\nPlease verify this has occured and view the applicable log\n\\\\agdev\\ftp\\CLIENTS\\comprehensive\\fromCLIENT\\Archive\\Log",

"From: CCGActivity\n");

?>


mapdrives

mount -t smbfs -o username=user,password=passwd //agapp/mars3 /mnt/agappmars3

mount -t smbfs -o username=user,password=passwd //agdev/ftp /mnt/agdevftp


movefile

cd /root/ftp/files

mv *.pgp /mnt/agdevftp/CLIENTS/comprehensive/fromCLIENT/Archive/

mv * /mnt/agappmars3/EDIFILES/CCG/fromClient

Samba Config

smb.conf

***************************************************************

# This is the main Samba configuration file. You should read the

# smb.conf(5) manual page in order to understand the options listed

# here. Samba has a huge number of configurable options (perhaps too

# many!) most of which are not shown in this example

#

# Any line which starts with a ; (semi-colon) or a # (hash)

# is a comment and is ignored. In this example we will use a #

# for commentry and a ; for parts of the config file that you

# may wish to enable

#

# NOTE: Whenever you modify this file you should run the command "testparm"

# to check that you have not made any basic syntactic errors.

#

#======================= Global Settings =====================================

[global]


# workgroup = NT-Domain-Name or Workgroup-Name

workgroup = aghealth123


# server string is the equivalent of the NT Description field

server string = samba server


# This option is important for security. It allows you to restrict

# connections to machines which are on your local network. The

# following example restricts access to two C class networks and

# the "loopback" interface. For more examples of the syntax see

# the smb.conf man page

; hosts allow = 192.168.1. 192.168.2. 127.

hosts allow = 10.10.10.


# if you want to automatically load your printer list rather

# than setting them up individually then you'll need this

printcap name = /etc/printcap

load printers = yes


# It should not be necessary to spell out the print system type unless

# yours is non-standard. Currently supported print systems include:

# bsd, sysv, plp, lprng, aix, hpux, qnx, cups

printing = cups


# Uncomment this if you want a guest account, you must add this to /etc/passwd

# otherwise the user "nobody" is used

; guest account = pcguest


# this tells Samba to use a separate log file for each machine

# that connects

log file = /var/log/samba/%m.log


# Put a capping on the size of the log files (in Kb).

max log size = 0


# Security mode. Most people will want user level security. See

# security_level.txt for details.

security = user


# Use password server option only with security = server

# The argument list may include:

# password server = My_PDC_Name [My_BDC_Name] [My_Next_BDC_Name]

# or to auto-locate the domain controller/s

# password server = *

; password server =


# Password Level allows matching of _n_ characters of the password for

# all combinations of upper and lower case.

; password level = 8

; username level = 8


# You may wish to use password encryption. Please read

# ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation.

# Do not enable this option unless you have read those documents

encrypt passwords = yes

smb passwd file = /etc/samba/smbpasswd


# The following is needed to keep smbclient from spouting spurious errors

# when Samba is built with support for SSL.

; ssl CA certFile = /usr/share/ssl/certs/ca-bundle.crt


# The following are needed to allow password changing from Windows to

# update the Linux system password also.

# NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above.

# NOTE2: You do NOT need these to allow workstations to change only

# the encrypted SMB passwords. They allow the Unix password

# to be kept in sync with the SMB password.

; unix password sync = Yes

; passwd program = /usr/bin/passwd %u

; passwd chat = *New*password* %n\n *Retype*new*password* %n\n *passwd:*all*authentication*tokens*updated*successfully*


# You can use PAM's password change control flag for Samba. If

# enabled, then PAM will be used for password changes when requested

# by an SMB client instead of the program listed in passwd program.

# It should be possible to enable this without changing your passwd

# chat parameter for most setups.


; pam password change = yes


# Unix users can map to different SMB User names

; username map = /etc/samba/smbusers


# Using the following line enables you to customise your configuration

# on a per machine basis. The %m gets replaced with the netbios name

# of the machine that is connecting

; include = /etc/samba/smb.conf.%m


# This parameter will control whether or not Samba should obey PAM's

# account and session management directives. The default behavior is

# to use PAM for clear text authentication only and to ignore any

# account or session management. Note that Samba always ignores PAM

# for authentication in the case of encrypt passwords = yes


; obey pam restrictions = yes


# Most people will find that this option gives better performance.

# See speed.txt and the manual pages for details

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192


# Configure Samba to use multiple interfaces

# If you have multiple network interfaces then you must list them

# here. See the man page for details.

; interfaces = 192.168.12.2/24 192.168.13.2/24


# Configure remote browse list synchronisation here

# request announcement to, or browse list sync from:

# a specific host or from / to a whole subnet (see below)

; remote browse sync = 192.168.3.25 192.168.5.255

# Cause this host to announce itself to local subnets here

; remote announce = 192.168.1.255 192.168.2.44


# Browser Control Options:

# set local master to no if you don't want Samba to become a master

# browser on your network. Otherwise the normal election rules apply

; local master = no


# OS Level determines the precedence of this server in master browser

# elections. The default value should be reasonable

; os level = 33


# Domain Master specifies Samba to be the Domain Master Browser. This

# allows Samba to collate browse lists between subnets. Don't use this

# if you already have a Windows NT domain controller doing this job

; domain master = yes


# Preferred Master causes Samba to force a local browser election on startup

# and gives it a slightly higher chance of winning the election

; preferred master = yes


# Enable this if you want Samba to be a domain logon server for

# Windows95 workstations.

; domain logons = yes


# if you enable domain logons then you may want a per-machine or

# per user logon script

# run a specific logon batch file per workstation (machine)

; logon script = %m.bat

# run a specific logon batch file per username

; logon script = %U.bat


# Where to store roving profiles (only for Win95 and WinNT)

# %L substitutes for this servers netbios name, %U is username

# You must uncomment the [Profiles] share below

; logon path = \\%L\Profiles\%U


# Windows Internet Name Serving Support Section:

# WINS Support - Tells the NMBD component of Samba to enable it's WINS Server

; wins support = yes


# WINS Server - Tells the NMBD components of Samba to be a WINS Client

# Note: Samba can be either a WINS Server, or a WINS Client, but NOT both

; wins server = w.x.y.z

wins server = 10.10.10.13


# WINS Proxy - Tells Samba to answer name resolution queries on

# behalf of a non WINS capable client, for this to work there must be

# at least one WINS Server on the network. The default is NO.

; wins proxy = yes


# DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names

# via DNS nslookups. The built-in default for versions 1.9.17 is yes,

# this has been changed in version 1.9.18 to no.

username map = /etc/samba/smbusers

dns proxy = no


# Case Preservation can be handy - system default is _no_

# NOTE: These can be set on a per share basis

; preserve case = no

; short preserve case = no

# Default case is normally upper case for all DOS files

; default case = lower

# Be very careful with case sensitivity - it can break things!

; case sensitive = no


#============================ Share Definitions ==============================

;[homes]

; comment = Home Directories

; browseable = no

; writeable = yes

; valid users = %S

; create mode = 0664

; directory mode = 0775

;# If you want users samba doesn't recognize to be mapped to a guest user

;; map to guest = bad user


# Un-comment the following and create the netlogon directory for Domain Logons

; [netlogon]

; comment = Network Logon Service

; path = /usr/local/samba/lib/netlogon

; guest ok = yes

; writable = no

; share modes = no


# Un-comment the following to provide a specific roving profile share

# the default is to use the user's home directory

;[Profiles]

; path = /usr/local/samba/profiles

; browseable = no

; guest ok = yes


# NOTE: If you have a BSD-style print system there is no need to

# specifically define each individual printer

;[printers]

; comment = All Printers

; path = /var/spool/samba

; browseable = no

;# Set public = yes to allow user 'guest account' to print

; printable = yes


# This one is useful for people to share files

;[tmp]

; comment = Temporary file space

; path = /tmp

; read only = no

; public = yes


# A publicly accessible directory, but read only, except for people in

# the "staff" group

;[public]

; comment = Public Stuff

; path = /home/samba

; public = yes

; writable = yes

; printable = no

; write list = @staff


# Other examples.

#

# A private printer, usable only by fred. Spool data will be placed in fred's

# home directory. Note that fred must have write access to the spool directory,

# wherever it is.

;[fredsprn]

; comment = Fred's Printer

; valid users = fred

; path = /home/fred

; printer = freds_printer

; public = no

; writable = no

; printable = yes


# A private directory, usable only by fred. Note that fred requires write

# access to the directory.

;[fredsdir]

; comment = Fred's Service

; path = /usr/somewhere/private

; valid users = fred

; public = no

; writable = yes

; printable = no


# a service which has a different directory for each machine that connects

# this allows you to tailor configurations to incoming machines. You could

# also use the %U option to tailor it by user name.

# The %m gets replaced with the machine name that is connecting.

;[pchome]

; comment = PC Directories

; path = /usr/local/pc/%m

; public = no

; writable = yes


# A publicly accessible directory, read/write to all users. Note that all files

# created in the directory by users will be owned by the default user, so

# any user with access can delete any other user's files. Obviously this

# directory must be writable by the default user. Another user could of course

# be specified, in which case all files would be owned by that user instead.

;[public]

; path = /usr/somewhere/else/public

; public = yes

; only guest = yes

; writable = yes

; printable = no


# The following two entries demonstrate how to share a directory so that two

# users can place files there that will be owned by the specific users. In this

# setup, the directory should be writable by both users and should have the

# sticky bit set on it to prevent abuse. Obviously this could be extended to

# as many users as required.

;[myshare]

; comment = Mary's and Fred's stuff

; path = /usr/somewhere/shared

; valid users = mary fred

; public = no

; writable = yes

; printable = no

; create mask = 0765


[mysql]

comment = mysql database backup share

valid users = backup will

path = /var/lib/mysql

writeable = yes

printable = no

create mask = 0765


[shared]

comment = shared transfer share

valid users = backup will

path = /home/trans

writeable = yes

printable = no

create mask = 0765


smb.conf (Condensed Version)

***************************************************************


#

#======================= Global Settings =====================================

[global]

workgroup = aghealth123

server string = samba server

hosts allow = 10.10.10.

printcap name = /etc/printcap

load printers = yes

printing = cups

log file = /var/log/samba/%m.log

max log size = 0

security = user

encrypt passwords = yes

smb passwd file = /etc/samba/smbpasswd

socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192

wins server = 10.10.10.13

username map = /etc/samba/smbusers

dns proxy = no


#============================ Share Definitions ==============================

[mysql]

comment = mysql database backup share

valid users = backup will

path = /var/lib/mysql

writeable = yes

printable = no

create mask = 0765


[shared]

comment = shared transfer share

valid users = backup will

path = /home/trans

writeable = yes

printable = no

create mask = 0765


smbusers

***************************************************************

# Unix_name = SMB_name1 SMB_name2 ...

root = administrator admin

nobody = guest pcguest smbguest

will = will

backup = backup

FTP Monitor Scripts

These are scripts I use to monitor and FTP site. It's ruff and still needs work but it's operational.

CHECK

#This script written by Will Hughes 3 OCT 03
#This script along with it's associated support scipts
#are designed to ssh or telnet into a remote box,
#do a directory listing, ftp back that listing,
#compare that listing with a default listing, and
#email back a notification if changes have been made.

#Transwestern script ssh's into box, does ls, and ftp's the results back
./transwestern

#Compares the ls results with a defualt set of ls results
#If ls results have changed then it emails vi the notify script
#The file newfile is being used as a flag indicating that a
#file has been recieved. This is to prevent multiple logs of new
#files as well as mutiple email notification.

if diff --brief list list.default
then
if [ -f newfile ]
then
rm -f newfile
echo "`date` File has downloaded" >> status
else
echo "`date`" >> status
fi
else
if [ -f newfile ]
then
echo "`date` File not downloaded" >> status
else
./notify
echo "`date` File Received" >> status
echo "`date` File Received" > newfile
fi
fi

NOTIFY

#!/usr/bin/expect -f
#

set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

set timeout -1
spawn telnet localhost 25
match_max 100000
expect "220 localhost.localdomain ESMTP Sendmail"
send -- "helo will\r"
expect -exact "helo will\r
250 localhost.localdomain Hello tuxbert \[127.0.0.1\], pleased to meet you\r
"
send -- "mail from:tuxbert@williamhughes.net\r"
expect -exact "mail from:tuxbert@williamhughes.net\r
250 2.1.0 tuxbert@williamhughes.net... Sender ok\r
"
send -- "rcpt to:will@aghealth123.com\r"
expect -exact "rcpt to:will@aghealth123.com\r
250 2.1.5 will@aghealth123.com... Recipient ok\r
"
send -- "data\r"
expect -exact "data\r
354 Enter mail, end with \".\" on a line by itself\r
"
send -- "subject:Transwestern file received\r"
expect -exact "subject:Transwestern file received\r
"
send -- "Transwestern file received\r"
expect -exact "Transwestern file received\r
"
send -- ".\r"
expect "Message accepted for delivery\r
"
send -- "quit\r"
expect eof

#!/usr/bin/expect -f
set force_conservative 0 ;# set to 1 to force conservative mode even if
;# script wasn't run conservatively originally
if {$force_conservative} {
set send_slow {1 .1}
proc send {ignore arg} {
sleep .1
exp_send -s -- $arg
}
}

set timeout -1
spawn ssh -l aguser 67.119.161.21
match_max 100000
expect -exact "aguser@67.119.161.21's password: "
send -- "\r"
expect -exact "\r
\[aguser@frs-web aguser\]\$ "
send -- "cd Claim"
expect -exact "im"
send -- "s\r"
expect -exact "s\r
\[aguser@frs-web Claims\]\$ "
send -- "ls > li"
expect -exact "li"
send -- "st\r"
expect -exact "st\r
\[aguser@frs-web Claims\]\$ "
send -- "ftp tuxbert.williamhughes.net"
expect -exact "mhughes.net"
send -- "\r"
expect -exact "\r
Connected to tuxbert.williamhughes.net (67.97.96.8Cool.\r
220 (vsFTPd 1.1.3)\r
Name (tuxbert.williamhughes.net:aguser): "
send -- "will\r"
expect -exact "will\r
331 Please specify the password.\r
Password:"
send -- "\r"
expect -exact "\r
230 Login successful. Have fun.\r
Remote system type is UNIX.\r
Using binary mode to transfer files.\r
\r\rftp> \rftp> "
send -- "c"
expect -exact "\rftp> c\rftp> c"
send -- "d"
expect -exact "\rftp> cd\rftp> cd"
send -- " "
expect -exact "\rftp> cd \rftp> cd "
send -- "t"
expect -exact "\rftp> cd t\rftp> cd t"
send -- "r"
expect -exact "\rftp> cd tr\rftp> cd tr"
send -- "a"
expect -exact "\rftp> cd tra\rftp> cd tra"
send -- "n"
expect -exact "\rftp> cd tran\rftp> cd tran"
send -- "s"
expect -exact "\rftp> cd trans\rftp> cd trans"
send -- "\r"
expect -exact "\r
250 Directory successfully changed.\r
\r\rftp> \rftp> "
send -- "s"
expect -exact "\rftp> s\rftp> s"
send -- "e"
expect -exact "\rftp> se\rftp> se"
send -- "n"
expect -exact "\rftp> sen\rftp> sen"
send -- "d"
expect -exact "\rftp> send\rftp> send"
send -- " "
expect -exact "\rftp> send \rftp> send "
send -- "li"
expect -exact "\rftp> send l\rftp> send l\rftp> send li\rftp> send li"
send -- "s"
expect -exact "\rftp> send lis\rftp> send lis"
send -- "t"
expect -exact "\rftp> send list\rftp> send list"
send -- "\r"
expect ")\r
\r\rftp> \rftp> "
send -- "b"
expect -exact "\rftp> b\rftp> b"
send -- "y"
expect -exact "\rftp> by\rftp> by"
send -- "e"
expect -exact "\rftp> bye\rftp> bye"
send -- "\r"
expect -exact "\r
221 Goodbye.\r
\[aguser@frs-web Claims\]\$ "
send -- "rm list\r"
expect -exact "rm list\r
\[aguser@frs-web Claims\]\$ "
send -- "exit\r"
expect eof

Netscreen Backup Script

Uses autoexec to suck down the configs....

#Create the directory. This is a "log" followed by Year, Month, and Day.
mkdir log`date '+%Y%m%d'`

#Datacenter 204 Backup
./datacenter204.exp > log`date '+%Y%m%d'`/datacenter204

#Datacenter 100
./datacenter100.exp > log`date '+%Y%m%d'`/datacenter100

#Dallas 10 Backup
./dallas10.exp > log`date '+%Y%m%d'`/dallas10

#Anaheim 5XP
./anaheim5xp.exp > log`date '+%Y%m%d'`/anaheim5xp

#Chicago 5XP
./chicago5xp.exp > log`date '+%Y%m%d'`/chicago5xp

#Colorado Springs 5XP
./cosprings5xp.exp > log`date '+%Y%m%d'`/cosprings5xp

#Milpitas 5XP
./milpitas5xp.exp > log`date '+%Y%m%d'`/milpitas5xp

#San Jose 10
./sanjose10.exp > log`date '+%Y%m%d'`/sanjose10

#Sterling 5XP
./sterling5xp.exp > log`date '+%Y%m%d'`/sterling5xp

#Tempe 5XP
./tempe5xp.exp > log`date '+%Y%m%d'`/tempe5xp

#Toronto 10
./toronto10.exp > log`date '+%Y%m%d'`/toronto10

Proftp Config File

ServerName "Dynamic Details Texas, L.P."
ServerAdmin mis@gm.ddiglobal.com
ServerType standalone
ServerIdent on "Dynamic Details Texas, L.P."
DeferWelcome on
Port 21
Umask 022

AllowOverwrite on

User ftp
Group nobody
UserAlias anonymous ftp
MaxClients 10
RequireValidShell on
AnonRequirePassword off
AuthAliasOnly on

DenyAll
AllowALL
DefaultRoot / pimpdaddy
DefaultRoot ~ ftpusers
DefaultRoot /home2/ftp ftpadmins
DefaultRoot ~