# Dataforth DOS Test Machines Project

**Client:** Dataforth Corporation
**Status:** 90% Complete, Working
**Project Start:** 2025-12-14
**Last Updated:** 2026-01-22

## Project Overview

Automated update and management system for approximately 30 DOS 6.22 test stations running QuickBASIC 4.5 data acquisition software at Dataforth's engineering facility.

**Primary Challenge:** Legacy DOS machines require SMB1 protocol, Windows Kerberos authentication incompatible with DOS networking.

**Solution:** D2TESTNAS (TrueNAS) acts as SMB1-to-SMB2 proxy with bidirectional sync to AD2 production server.

---

## Architecture

```
┌─────────────────┐         ┌─────────────────┐         ┌─────────────────┐
│  DOS Machines   │◄──SMB1─►│   D2TESTNAS     │◄──SMB2─►│      AD2        │
│   (TS-XX)       │         │  (192.168.0.9)  │         │ (192.168.0.6)   │
│  DOS 6.22       │         │  TrueNAS/proxy  │         │ Production Svr  │
└─────────────────┘         └─────────────────┘         └─────────────────┘
                                    │
                                    │ Sync every 15 min
                                    ▼
                            [Bidirectional Sync]
                            /root/sync-to-ad2.sh
```

---

## Network Configuration

| Device | IP | Role | OS | Credentials |
|--------|-----|------|-----|-------------|
| D2TESTNAS | 192.168.0.9 | NAS/SMB1 proxy | TrueNAS | admin / Paper123!@#-nas |
| AD2 | 192.168.0.6 | Production server | Windows Server 2008 R2 | INTRANET\sysadmin / Paper123!@# |
| UDM | 192.168.0.254 | Gateway/Router | UniFi Dream Machine | admin / [see credentials.md] |
| DOS Stations | 192.168.0.x | Test stations (TS-XX) | DOS 6.22 | N/A |

**Network:** 192.168.0.0/24 (Dataforth engineering network)

---

## Key Components

### 1. SMB Shares

#### D2TESTNAS Shares (SMB1)
- **test:** `/data/test/` - Main working share for DOS machines
- **datasheets:** `/data/datasheets/` - Engineering documentation and configs

#### AD2 Shares (SMB2)
- **\\AD2\test** - C:\Shares\test\ (production working directory)
- **\\AD2\datasheets** - PENDING (waiting on Engineering input)

### 2. UPDATE.BAT - Remote Management Utility

**Location:**
- NAS: `/data/test/UPDATE.BAT`
- AD2: `C:\Shares\test\UPDATE.BAT`
- DOS: `T:\UPDATE.BAT` (via mapped drive)

**Usage:**
```batch
REM Update all components for station TS-27
T:\UPDATE TS-27 ALL

REM Update specific component
T:\UPDATE TS-27 GPIB
T:\UPDATE TS-27 AUTOEXEC
```

**Functions:**
- Deploys configuration files from central location
- Updates AUTOEXEC.BAT, CONFIG.SYS
- Syncs GPIB drivers and QuickBASIC modules
- Creates station-specific directories

### 3. TODO.BAT - Automated Task Execution

**Location:** `T:\TS-XX\TODO.BAT` (created by admin on AD2)

**Behavior:**
- Placed in station-specific folder: `\\AD2\test\TS-XX\TODO.BAT`
- Sync copies to NAS (every 15 min)
- DOS machine runs on boot via AUTOEXEC.BAT
- Automatically deletes after execution
- Results logged to `TS-XX\TODO.LOG`

**Example Use Cases:**
- Remote diagnostic commands
- Configuration updates
- File collection
- System information gathering

### 4. Bidirectional Sync System

**Script:** `/root/sync-to-ad2.sh` on D2TESTNAS

**Credentials:** `/root/.ad2creds`
```
username=sysadmin
password=Paper123!@#
domain=INTRANET
```

**Log:** `/var/log/ad2-sync.log`

**Schedule:** Every 15 minutes via cron
```cron
*/15 * * * * /root/sync-to-ad2.sh >> /var/log/ad2-sync.log 2>&1
```

**Sync Strategy:**
- **NAS → AD2:** rsync with --update (newer files win)
- **AD2 → NAS:** rsync with --update (newer files win)
- **Deletions:** Not synced (safety measure)
- **Conflicts:** Newer timestamp wins

**Monitoring:**
```bash
# View recent sync activity
ssh root@192.168.0.9 'tail -50 /var/log/ad2-sync.log'

# Check sync status file
smbclient //192.168.0.6/test -U sysadmin%'Paper123!@#' -c 'get _SYNC_STATUS.txt -'
```

---

## DOS Machine Configuration

### Network Setup
Each DOS station uses Microsoft Network Client 3.0:

**AUTOEXEC.BAT:**
```batch
@ECHO OFF
C:\NET\NET START
NET USE T: \\D2TESTNAS\TEST
IF EXIST T:\TS-XX\TODO.BAT CALL T:\TS-XX\TODO.BAT
```

**PROTOCOL.INI:**
- Workgroup: WORKGROUP
- ComputerName: TS-XX
- Protocol: NetBEUI over SMB1 CORE

### WINS Configuration
**Critical:** WINS server (192.168.0.254) required for NetBIOS name resolution.

Without WINS, DOS machines cannot resolve `\\D2TESTNAS` to 192.168.0.9.

---

## File Locations

### On D2TESTNAS (192.168.0.9)
```
/data/test/
├── UPDATE.BAT              # Central management utility
├── TS-XX/                  # Per-station folders
│   ├── TODO.BAT           # Remote task (if present)
│   └── TODO.LOG           # Task execution log
├── CONFIGS/               # Master config templates
├── GPIB/                  # GPIB driver files
└── _SYNC_STATUS.txt       # Last sync timestamp

/data/datasheets/
└── CONFIGS/               # Full DOS image from TS-27
    └── [1790 files, 44MB]
```

### On AD2 (192.168.0.6)
```
C:\Shares\test\
├── UPDATE.BAT
├── TS-XX\
│   ├── TODO.BAT
│   └── TODO.LOG
├── CONFIGS\
├── GPIB\
└── _SYNC_STATUS.txt
```

### On DOS Machines
```
C:\
├── AUTOEXEC.BAT          # Network startup + TODO execution
├── CONFIG.SYS            # Device drivers
├── NET\                  # Network client files
├── GPIB\                 # GPIB ISA card drivers
└── QB45\                 # QuickBASIC 4.5

T:\ (mapped to \\D2TESTNAS\TEST)
├── UPDATE.BAT
├── TS-XX\
│   └── TODO.BAT (if present)
└── [shared files]
```

---

## Common Operations

### Accessing Infrastructure

#### SSH to NAS
```bash
ssh root@192.168.0.9
# Uses ed25519 key from ~/.ssh/id_ed25519
```

#### SMB to NAS (from Windows)
```bash
# Via PowerShell
New-SmbMapping -LocalPath T: -RemotePath \\192.168.0.9\test -UserName admin -Password Paper123!@#-nas

# Via Command Prompt
net use T: \\192.168.0.9\test /user:admin Paper123!@#-nas
```

#### SMB to AD2
```bash
# Via PowerShell (from GuruRMM/Jupiter)
$password = ConvertTo-SecureString 'Paper123!@#' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('INTRANET\sysadmin', $password)
New-PSDrive -Name AD2 -PSProvider FileSystem -Root "\\192.168.0.6\C$" -Credential $cred
```

### Deploying Updates to DOS Machines

#### Method 1: UPDATE.BAT (Normal Operation)
```batch
REM Edit UPDATE.BAT on AD2
\\192.168.0.6\test\UPDATE.BAT

REM Wait for sync (every 15 min) or trigger manually:
ssh root@192.168.0.9 '/root/sync-to-ad2.sh'

REM On DOS machine:
T:\UPDATE TS-XX ALL
```

#### Method 2: TODO.BAT (Remote Execution)
```batch
REM Create TODO.BAT on AD2
echo DIR C:\ > \\192.168.0.6\test\TS-27\TODO.BAT

REM Wait for sync
REM DOS machine runs on next boot, then deletes TODO.BAT

REM Check results
type \\192.168.0.6\test\TS-27\TODO.LOG
```

### Monitoring Sync

```bash
# View sync log
ssh root@192.168.0.9 'tail -50 /var/log/ad2-sync.log'

# Check last sync status
smbclient //192.168.0.6/test -U sysadmin%'Paper123!@#' -c 'get _SYNC_STATUS.txt -'

# Manual sync trigger
ssh root@192.168.0.9 '/root/sync-to-ad2.sh'
```

### Testing DOS Machine

```batch
REM From DOS machine:
C:\NET\NET VIEW
C:\NET\NET USE
DIR T:\

REM Test UPDATE.BAT
T:\UPDATE TS-XX ALL

REM Check for TODO.BAT
IF EXIST T:\TS-XX\TODO.BAT TYPE T:\TS-XX\TODO.BAT
```

---

## Tested Machines

| Station | Status | Last Test | Notes |
|---------|--------|-----------|-------|
| TS-27 | ✅ Working | 2025-12-14 | Reference machine, full config captured |
| TS-8L | ✅ Working | 2025-12-14 | Network config updated |
| TS-8R | ✅ Working | 2025-12-14 | Network config updated |
| TS-XX (others) | ⏳ Pending | N/A | ~27 machines need config updates |

---

## Remaining Tasks

### High Priority
- [ ] Create `\\AD2\datasheets` share (waiting on Engineering input for folder location)
- [ ] Update network configuration on remaining ~27 DOS machines
- [ ] Document QuickBASIC application details (if Engineering provides info)

### Medium Priority
- [ ] Create comprehensive DOS machine inventory
- [ ] Test TODO.BAT on all stations
- [ ] Set up automated health monitoring

### Low Priority
- [ ] Explore VPN access for remote management
- [ ] Investigate modern DOS alternatives (FreeDOS, etc.)
- [ ] Create backup/restore procedures for DOS machine images

---

## Troubleshooting

### DOS Machine Cannot Access T: Drive

**Check:**
1. Network cable connected?
2. WINS server reachable? `ping 192.168.0.254`
3. NetBIOS name resolution? Try IP: `NET USE T: \\192.168.0.9\TEST`
4. NAS share accessible? Test from Windows: `\\192.168.0.9\test`

**Common Fixes:**
- Restart network client: `C:\NET\NET STOP` then `C:\NET\NET START`
- Check PROTOCOL.INI for typos
- Verify WINS server setting in UDM

### Sync Not Working

**Check:**
1. Cron running? `ssh root@192.168.0.9 'ps aux | grep cron'`
2. Credentials valid? `cat /root/.ad2creds`
3. SMB mount successful? `ssh root@192.168.0.9 'mount | grep /mnt/ad2-test'`
4. Recent errors? `ssh root@192.168.0.9 'tail -50 /var/log/ad2-sync.log'`

**Common Fixes:**
- Re-mount AD2 share: Run sync script manually
- Check AD2 reachability: `ping 192.168.0.6`
- Verify sysadmin credentials

### UPDATE.BAT Fails

**Check:**
1. Batch file has DOS line endings (CR+LF)?
2. Paths correct for DOS (8.3 format if needed)?
3. Files exist on T: drive?
4. Sufficient disk space on C: drive?

**Common Fixes:**
- Convert line endings: `unix2dos UPDATE.BAT`
- Test manually: Run commands one by one
- Check sync: Files may not be on NAS yet

---

## Technical Details

### DOS 6.22 Limitations
- **Filenames:** 8.3 format only (FILENAME.EXT)
- **Line Endings:** CR+LF (\\r\\n) required for batch files
- **Networking:** SMB1 CORE protocol only
- **Authentication:** No Kerberos, plaintext passwords
- **Memory:** 640KB conventional + extended via HIMEM.SYS

### SMB Protocol Versions
- **SMB1 CORE:** DOS machines (1985, insecure)
- **SMB1:** Windows XP / Server 2003
- **SMB2:** Windows Vista / Server 2008+
- **SMB3:** Windows 8 / Server 2012+

### TrueNAS Configuration
- SMB service enabled with SMB1 support
- Guest access disabled
- User: admin with password authentication
- Shares: test, datasheets

---

## Documentation

### Original Implementation
**Session Log:** `~/claude-projects/session-logs/2025-12-14-dataforth-dos-machines.md`
**Implementation Time:** ~11 hours
**Date:** 2025-12-14

### Additional Documentation
- **CREDENTIALS.md** - All access credentials
- **NETWORK_TOPOLOGY.md** - Network diagram and IP addresses
- **SYNC_SCRIPT.md** - Bidirectional sync documentation
- **DOS_BATCH_FILES.md** - UPDATE.BAT and TODO.BAT details
- **GITEA_ACCESS.md** - Repository access instructions
- **PROJECT_INDEX.md** - Quick reference guide

### Source Repository
```bash
git clone --no-checkout https://git.azcomputerguru.com/azcomputerguru/claude-projects.git
cd claude-projects
git sparse-checkout init --cone
git sparse-checkout set dataforth-dos
git checkout main
```

---

## Project History

**2025-12-14:** Initial implementation, sync system created, TS-27/TS-8L/TS-8R tested
**2025-12-20:** VPN access configured for remote management
**2026-01-13:** Dataforth DOS project recalled for additional work
**2026-01-19:** DOS deployment verification, AD2-NAS sync enhancements
**2026-01-20:** DOS Update System comprehensive documentation created
**2026-01-22:** Project documentation imported to ClaudeTools

---

## Support Contacts

**Client:** Dataforth Corporation
**Engineering Contact:** [Pending]
**Network Administrator:** [Pending]

**Technical Support:**
- Arizona Computer Guru (MSP)
- Phone: 520.304.8300
- Email: support@azcomputerguru.com

---

## Related Projects

- **GuruRMM:** Remote monitoring system (AD2 has agent installed)
- **ClaudeTools:** Project tracking and documentation system
- **Session Logs:** Complete work history in claude-projects/session-logs/

---

**Project Status:** 90% Complete, Operational
**Next Steps:** Datasheets share creation, remaining machine configs
**Maintenance:** Automated sync, minimal intervention required
