# Dataforth DOS Update System - Deployment Guide

**Version:** 1.0
**Date:** 2026-01-19
**Target System:** DOS 6.22 with Microsoft Network Client 3.0

---

## Table of Contents

1. [Pre-Deployment Checklist](#pre-deployment-checklist)
2. [Network Infrastructure Setup](#network-infrastructure-setup)
3. [Deploy Batch Files](#deploy-batch-files)
4. [Configure DOS Machines](#configure-dos-machines)
5. [Test Update System](#test-update-system)
6. [Deploy to All Machines](#deploy-to-all-machines)
7. [Post-Deployment Verification](#post-deployment-verification)
8. [Troubleshooting](#troubleshooting)

---

## Pre-Deployment Checklist

### Required Information

- [ ] List of DOS machine names (e.g., TS-4R, TS-7A, TS-12B)
- [ ] AD2 workstation IP address: 192.168.0.6
- [ ] D2TESTNAS IP address: 192.168.0.9
- [ ] SMB1 protocol enabled on NAS: YES / NO
- [ ] Sync-FromNAS.ps1 script running on AD2: YES / NO (Scheduled task every 15 min)
- [ ] Network credentials verified: YES / NO

### Required Access

- [ ] Admin access to AD2 workstation
- [ ] SSH access to D2TESTNAS (guru account)
- [ ] Physical or remote access to DOS machines
- [ ] DattoRMM access (for monitoring)

### Required Files

All batch files should be in `D:\ClaudeTools\`:

- [ ] NWTOC.BAT - Network to Computer update
- [ ] CTONW.BAT - Computer to Network upload
- [ ] UPDATE.BAT - Full system backup
- [ ] STAGE.BAT - System file staging
- [ ] REBOOT.BAT - System file application
- [ ] CHECKUPD.BAT - Update checker
- [ ] STARTNET.BAT - Network startup
- [ ] AUTOEXEC.BAT - System startup template

---

## Network Infrastructure Setup

### Step 1: Verify NAS Share Structure

**On D2TESTNAS (SSH as guru):**

```bash
# Check if test share exists
ls -la /mnt/test

# Create directory structure if needed
sudo mkdir -p /mnt/test/COMMON/ProdSW
sudo mkdir -p /mnt/test/COMMON/DOS
sudo mkdir -p /mnt/test/COMMON/NET

# Create machine-specific directories
sudo mkdir -p /mnt/test/TS-4R/ProdSW
sudo mkdir -p /mnt/test/TS-4R/BACKUP
sudo mkdir -p /mnt/test/TS-7A/ProdSW
sudo mkdir -p /mnt/test/TS-7A/BACKUP
sudo mkdir -p /mnt/test/TS-12B/ProdSW
sudo mkdir -p /mnt/test/TS-12B/BACKUP

# Set permissions
sudo chmod -R 775 /mnt/test
sudo chown -R guru:users /mnt/test
```

### Step 2: Verify AD2 Sync Script

**IMPORTANT:** Sync runs ON AD2 (not NAS) due to WINS crashes and SSH lockups on NAS.

**Check sync script exists on AD2:**

```powershell
# RDP or SSH to AD2 (192.168.0.6)
# Check if script exists
Test-Path "C:\Shares\test\scripts\Sync-FromNAS.ps1"

# View last sync status
Get-Content "C:\Shares\test\_SYNC_STATUS.txt"

# Check recent log entries
Get-Content "C:\Shares\test\scripts\sync-from-nas.log" -Tail 20
```

**Verify Scheduled Task:**

```powershell
# On AD2, check scheduled task
Get-ScheduledTask | Where-Object {$_.TaskName -like '*sync*'}

# View task details
Get-ScheduledTask -TaskName "Sync-FromNAS" | Get-ScheduledTaskInfo
```

**Expected scheduled task:**
- **Name:** Sync-FromNAS (or similar)
- **Runs:** Every 15 minutes
- **Script:** `C:\Shares\test\scripts\Sync-FromNAS.ps1`
- **User:** INTRANET\sysadmin or local admin

**How the sync works:**

1. **PULL (NAS → AD2):** Test results from DOS machines
   - `/data/test/TS-XX/LOGS/*.DAT` → `C:\Shares\test\TS-XX\LOGS\`
   - `/data/test/TS-XX/Reports/*.TXT` → `C:\Shares\test\TS-XX\Reports\`
   - Files are imported to database after sync
   - Files are deleted from NAS after successful sync

2. **PUSH (AD2 → NAS):** Software updates for DOS machines
   - `C:\Shares\test\COMMON\ProdSW\*` → `/data/test/COMMON/ProdSW/`
   - `C:\Shares\test\TS-XX\ProdSW\*` → `/data/test/TS-XX/ProdSW/`
   - `C:\Shares\test\UPDATE.BAT` → `/data/test/UPDATE.BAT`
   - `C:\Shares\test\TS-XX\TODO.BAT` → `/data/test/TS-XX/TODO.BAT` (one-shot tasks)

**Status file location:**
- `C:\Shares\test\_SYNC_STATUS.txt` (monitored by DattoRMM)
- Shows last sync time, files transferred, error count

**If scheduled task doesn't exist:**

Contact Dataforth IT administrator - scheduled task should have been created when sync was moved from NAS to AD2 (January 2026) to resolve WINS crashes.
```

### Step 3: Verify SMB1 Protocol

**Check SMB1 is enabled on NAS:**

```bash
# Check Samba configuration
grep "min protocol" /etc/samba/smb.conf

# Should show:
#   min protocol = NT1
# Or similar (NT1 = SMB1)

# If not present, add to [global] section:
sudo nano /etc/samba/smb.conf
```

Add to `[global]` section:
```
[global]
   min protocol = NT1
   max protocol = SMB3
   client min protocol = NT1
```

```bash
# Restart Samba
sudo systemctl restart smbd

# Verify from Windows:
# Open \\172.16.3.30 in File Explorer
# Should be able to access without errors
```

---

## Deploy Batch Files

### Step 1: Copy Batch Files to AD2

**From Windows workstation with D:\ClaudeTools access:**

Copy batch files to AD2 COMMON directory:

```powershell
# Set source and destination
$source = "D:\ClaudeTools"
$dest = "\\AD2\test\COMMON\ProdSW"

# Create destination directory if needed
New-Item -ItemType Directory -Path $dest -Force

# Copy batch files
Copy-Item "$source\NWTOC.BAT" "$dest\" -Force
Copy-Item "$source\CTONW.BAT" "$dest\" -Force
Copy-Item "$source\UPDATE.BAT" "$dest\" -Force
Copy-Item "$source\STAGE.BAT" "$dest\" -Force
Copy-Item "$source\CHECKUPD.BAT" "$dest\" -Force
Copy-Item "$source\STARTNET.BAT" "$dest\" -Force

# Don't copy REBOOT.BAT (it's auto-generated by STAGE.BAT)

# Verify
Get-ChildItem $dest -Filter *.BAT
```

### Step 2: Wait for NAS Sync

Wait up to 15 minutes for sync, or force sync:

```bash
# On NAS (SSH)
sudo /root/sync-to-ad2.sh

# Check status
cat /mnt/test/_SYNC_STATUS.txt
```

### Step 3: Verify Files on NAS

**From Windows, access NAS directly:**

```
\\172.16.3.30\test\COMMON\ProdSW\

Should contain:
  NWTOC.BAT
  CTONW.BAT
  UPDATE.BAT
  STAGE.BAT
  CHECKUPD.BAT
  STARTNET.BAT
```

---

## Configure DOS Machines

### Step 1: Access DOS Machine

**Physical access or remote console (TS-4R example):**

```
Power on machine
Boot to DOS
Wait for C:\> prompt
```

### Step 2: Verify Network Client

Check if Microsoft Network Client 3.0 is installed:

```bat
C:\> DIR C:\NET
```

Should show:
- STARTNET.BAT
- NET.EXE
- PROTOCOL.INI
- *.DOS files (network drivers)

If not installed, install Microsoft Network Client 3.0 first (separate procedure).

### Step 3: Update AUTOEXEC.BAT

**Edit AUTOEXEC.BAT to add MACHINE variable:**

```bat
C:\> EDIT C:\AUTOEXEC.BAT
```

**Add these lines near the top (after @ECHO OFF):**

```bat
@ECHO OFF
REM AUTOEXEC.BAT - DOS 6.22 startup script for Dataforth test machines

REM *** ADD THIS LINE - Change TS-4R to actual machine name ***
SET MACHINE=TS-4R

REM Set DOS path
SET PATH=C:\DOS;C:\NET;C:\BAT;C:\

REM Set command prompt
PROMPT $P$G

REM Set temporary directory
SET TEMP=C:\TEMP
SET TMP=C:\TEMP

REM Create required directories
IF NOT EXIST C:\TEMP\NUL MD C:\TEMP
IF NOT EXIST C:\BAT\NUL MD C:\BAT
IF NOT EXIST C:\ATE\NUL MD C:\ATE

REM Start network client and map drives
ECHO Starting network client...
IF EXIST C:\NET\STARTNET.BAT CALL C:\NET\STARTNET.BAT

REM Check if network started
IF NOT EXIST T:\NUL GOTO NET_FAILED
ECHO [OK] Network drives mapped
ECHO   T: = \\D2TESTNAS\test
ECHO   X: = \\D2TESTNAS\datasheets
ECHO.
ECHO System ready.
ECHO.
GOTO DONE

:NET_FAILED
ECHO [WARNING] Network drive mapping failed
ECHO To start network manually: C:\NET\STARTNET.BAT
ECHO.
PAUSE Press any key to continue...

:DONE
```

**Save and exit EDIT (Alt+F, X, Yes)**

### Step 4: Create/Update STARTNET.BAT

**Edit C:\NET\STARTNET.BAT:**

```bat
C:\> EDIT C:\NET\STARTNET.BAT
```

**Contents:**

```bat
@ECHO OFF
REM STARTNET.BAT - Start Microsoft Network Client and map drives

REM Start network client
NET START
IF ERRORLEVEL 1 GOTO NET_START_FAILED

ECHO [OK] Network client started

REM Map T: drive to test share
NET USE T: \\D2TESTNAS\test /YES
IF ERRORLEVEL 1 GOTO T_DRIVE_FAILED
ECHO [OK] T: mapped to \\D2TESTNAS\test

REM Map X: drive to datasheets share
NET USE X: \\D2TESTNAS\datasheets /YES
IF ERRORLEVEL 1 GOTO X_DRIVE_FAILED
ECHO [OK] X: mapped to \\D2TESTNAS\datasheets

GOTO END

:NET_START_FAILED
ECHO [ERROR] Network client failed to start
ECHO Check network cable and CONFIG.SYS drivers
GOTO END

:T_DRIVE_FAILED
ECHO [ERROR] Failed to map T: drive
ECHO Check if \\D2TESTNAS is online
GOTO END

:X_DRIVE_FAILED
ECHO [ERROR] Failed to map X: drive
ECHO Check if \\D2TESTNAS\datasheets exists
GOTO END

:END
```

**Save and exit**

### Step 5: Reboot DOS Machine

```bat
C:\> Press Ctrl+Alt+Del

[Machine reboots]
[AUTOEXEC.BAT runs]
[STARTNET.BAT maps network drives]
[Should see "Network drives mapped" message]
```

### Step 6: Verify Network Access

```bat
C:\> DIR T:\

Should show:
  COMMON
  TS-4R
  _SYNC_STATUS.txt

C:\> DIR T:\COMMON\ProdSW

Should show batch files:
  NWTOC.BAT
  CTONW.BAT
  UPDATE.BAT
  STAGE.BAT
  CHECKUPD.BAT
```

---

## Test Update System

### Test 1: Initial Update Pull (NWTOC)

**On DOS machine (TS-4R):**

```bat
C:\> NWTOC

Expected output:
==============================================================
Update: TS-4R from Network
==============================================================
Source: T:\COMMON and T:\TS-4R
Target: C:\BAT, C:\ATE, C:\NET
==============================================================

[1/4] Updating batch files from T:\COMMON\ProdSW...
      Creating backups (.BAK files)...
      Copying updated files...
      [OK] Batch files updated from COMMON

[2/4] Updating machine-specific files from T:\TS-4R\ProdSW...
      [SKIP] No machine-specific directory (T:\TS-4R\ProdSW)

[3/4] Checking for system file updates...
      [OK] No system file updates

[4/4] Checking for network client updates...
      [OK] No network client updates

==============================================================
Update Complete
==============================================================

Files updated from:
  T:\COMMON\ProdSW       → C:\BAT
  T:\TS-4R\ProdSW        → C:\BAT and C:\ATE
```

**Verify files were copied:**

```bat
C:\> DIR C:\BAT\*.BAT

Should show:
  NWTOC.BAT
  CTONW.BAT
  UPDATE.BAT
  STAGE.BAT
  CHECKUPD.BAT
```

### Test 2: Update Check (CHECKUPD)

```bat
C:\> CHECKUPD

Expected output:
==============================================================
Update Check: TS-4R
==============================================================

[1/3] Checking T:\COMMON\ProdSW for batch file updates...
      [OK] No updates in COMMON

[2/3] Checking T:\TS-4R\ProdSW for machine-specific updates...
      [SKIP] T:\TS-4R\ProdSW not found

[3/3] Checking T:\COMMON\DOS for system file updates...
      [OK] No system file updates

==============================================================
Update Summary
==============================================================

Available updates:
  Common files:           0
  Machine-specific files: 0
  System files:           0
  -----------------------------------
  Total:                  0

Status: All files are up to date
```

### Test 3: Full Backup (UPDATE)

```bat
C:\> UPDATE

Expected output:
==============================================================
Backup: Machine TS-4R
==============================================================
Source: C:\
Target: T:\TS-4R\BACKUP

Checking network drive T:...
[OK] T: drive accessible
[OK] Backup directory ready

Starting backup...
[OK] Backup completed successfully

Files backed up to: T:\TS-4R\BACKUP
```

**Verify backup:**

```bat
C:\> DIR T:\TS-4R\BACKUP

Should mirror C:\ structure:
  DOS
  NET
  BAT
  ATE
  TEMP
  AUTOEXEC.BAT
  CONFIG.SYS
```

### Test 4: Upload to Network (CTONW)

**Create test file:**

```bat
C:\> EDIT C:\BAT\TEST.BAT
```

**Contents:**
```bat
@ECHO OFF
ECHO This is a test file
PAUSE
```

**Save and upload:**

```bat
C:\> CTONW MACHINE

Expected output:
==============================================================
Upload: TS-4R to Network
==============================================================
Source: C:\BAT, C:\ATE
Target: T:\TS-4R\ProdSW
Target type: MACHINE
==============================================================

[OK] Target directory ready: T:\TS-4R\ProdSW

[1/2] Uploading batch files from C:\BAT...
      Creating backups on network (.BAK files)...
      Copying files to T:\TS-4R\ProdSW...
      [OK] Batch files uploaded

[2/2] Uploading programs and data from C:\ATE...
      [OK] Programs uploaded

==============================================================
Upload Complete
==============================================================
```

**Verify upload:**

```bat
C:\> DIR T:\TS-4R\ProdSW

Should show:
  TEST.BAT
```

### Test 5: System File Update (STAGE/REBOOT)

**Create test AUTOEXEC.NEW:**

```bat
C:\> COPY C:\AUTOEXEC.BAT C:\AUTOEXEC.NEW
C:\> EDIT C:\AUTOEXEC.NEW
```

**Add a comment to identify this as test version:**

```bat
@ECHO OFF
REM AUTOEXEC.BAT - DOS 6.22 startup script
REM *** TEST VERSION - Updated 2026-01-19 ***
```

**Save and copy to network:**

```bat
C:\> COPY C:\AUTOEXEC.NEW T:\COMMON\DOS\AUTOEXEC.NEW
```

**Run update:**

```bat
C:\> NWTOC

[Will detect AUTOEXEC.NEW]
[Will call STAGE.BAT automatically]

Expected output:
...
[3/4] Checking for system file updates...
      [FOUND] System file updates available
      Staging AUTOEXEC.BAT and/or CONFIG.SYS updates...

==============================================================
Staging System File Updates
==============================================================
  [STAGED] C:\AUTOEXEC.NEW → Will replace AUTOEXEC.BAT
==============================================================

[1/3] Backing up current system files...
      [OK] C:\AUTOEXEC.BAT → C:\AUTOEXEC.SAV

[2/3] Creating reboot update script...
      [OK] C:\BAT\REBOOT.BAT created

[3/3] Modifying AUTOEXEC.BAT for one-time reboot update...
      [OK] AUTOEXEC.BAT modified to run update on next boot

==============================================================
REBOOT REQUIRED
==============================================================

To apply updates now:
  1. Press Ctrl+Alt+Del to reboot

Press any key to return to DOS...
```

**Reboot machine:**

```bat
C:\> Press Ctrl+Alt+Del

[Machine reboots]
[AUTOEXEC.BAT calls REBOOT.BAT]

Expected output during boot:
==============================================================
Applying System Updates
==============================================================

[1/2] Updating AUTOEXEC.BAT...
      [OK] AUTOEXEC.BAT updated

==============================================================
System Updates Applied
==============================================================

Backup files saved:
  C:\AUTOEXEC.SAV - Previous AUTOEXEC.BAT
  C:\CONFIG.SAV - Previous CONFIG.SYS

To rollback changes:
  COPY C:\AUTOEXEC.SAV C:\AUTOEXEC.BAT

Press any key to continue boot...
```

**Verify update:**

```bat
C:\> TYPE C:\AUTOEXEC.BAT | FIND "TEST VERSION"

Should show:
  REM *** TEST VERSION - Updated 2026-01-19 ***
```

**Rollback test:**

```bat
C:\> COPY C:\AUTOEXEC.SAV C:\AUTOEXEC.BAT
C:\> Press Ctrl+Alt+Del to reboot
```

---

## Deploy to All Machines

### Deployment Order

1. **Test machine:** TS-4R (already done above)
2. **Pilot machines:** TS-7A, TS-12B (next 2-3 machines)
3. **Full rollout:** All remaining machines

### For Each Machine

**Repeat these steps for each DOS machine:**

1. **Update AUTOEXEC.BAT:**
   ```bat
   C:\> EDIT C:\AUTOEXEC.BAT
   [Add: SET MACHINE=TS-7A]  # Change to actual machine name
   [Save and exit]
   ```

2. **Reboot to activate network:**
   ```bat
   C:\> Press Ctrl+Alt+Del
   ```

3. **Verify network:**
   ```bat
   C:\> DIR T:\
   [Should show COMMON, machine directories]
   ```

4. **Initial update:**
   ```bat
   C:\> NWTOC
   [Pulls all batch files from network]
   ```

5. **Create backup:**
   ```bat
   C:\> UPDATE
   [Backs up to T:\[MACHINE]\BACKUP]
   ```

6. **Verify:**
   ```bat
   C:\> DIR C:\BAT\*.BAT
   [Should show all batch files]

   C:\> CHECKUPD
   [Should show "All files are up to date"]
   ```

### Create Machine-Specific Directories

**On AD2 or via SSH to NAS:**

```bash
# For each machine, create directories
sudo mkdir -p /mnt/test/TS-7A/ProdSW
sudo mkdir -p /mnt/test/TS-7A/BACKUP

sudo mkdir -p /mnt/test/TS-12B/ProdSW
sudo mkdir -p /mnt/test/TS-12B/BACKUP

# Set permissions
sudo chmod -R 775 /mnt/test
sudo chown -R guru:users /mnt/test
```

---

## Post-Deployment Verification

### Verification Checklist

For each DOS machine:

- [ ] MACHINE variable set correctly in AUTOEXEC.BAT
- [ ] Network drives map on boot (T: and X:)
- [ ] NWTOC downloads files successfully
- [ ] UPDATE backs up to network
- [ ] CHECKUPD reports status correctly
- [ ] CTONW uploads to network
- [ ] System file updates work (if tested)

### DattoRMM Monitoring

**Set up monitoring for:**

1. **Sync status:**
   - Monitor: `\\AD2\test\_SYNC_STATUS.txt`
   - Alert if: File age > 30 minutes
   - Alert if: Contains "ERROR"

2. **Backup status:**
   - Monitor: `\\AD2\test\TS-*\BACKUP` directories
   - Alert if: No files modified in 7 days

3. **NAS availability:**
   - Monitor: PING 172.16.3.30
   - Alert if: Down for > 5 minutes

### Test Update Distribution

**Deploy test batch file to all machines:**

1. **Create TEST-ALL.BAT:**
   ```bat
   @ECHO OFF
   ECHO Test file deployed to all machines
   ECHO Machine: %MACHINE%
   ECHO Date: 2026-01-19
   PAUSE
   ```

2. **Copy to COMMON:**
   ```powershell
   Copy-Item "C:\Temp\TEST-ALL.BAT" "\\AD2\test\COMMON\ProdSW\" -Force
   ```

3. **Wait for sync (15 min) or force:**
   ```bash
   sudo /root/sync-to-ad2.sh
   ```

4. **On each DOS machine:**
   ```bat
   C:\> CHECKUPD
   [Should show 1 update available]

   C:\> NWTOC
   [Should download TEST-ALL.BAT]

   C:\> C:\BAT\TEST-ALL.BAT
   [Should run correctly]
   ```

---

## Troubleshooting

### Problem: Network drives don't map on boot

**Symptoms:**
- T: and X: drives not available after boot
- STARTNET.BAT shows errors

**Solutions:**

1. **Check network cable:**
   ```bat
   C:\> NET VIEW
   [Should show \\D2TESTNAS]
   ```

2. **Manual map:**
   ```bat
   C:\> NET USE T: \\D2TESTNAS\test /YES
   C:\> NET USE X: \\D2TESTNAS\datasheets /YES
   ```

3. **Check PROTOCOL.INI:**
   ```bat
   C:\> TYPE C:\NET\PROTOCOL.INI
   [Verify computername, workgroup settings]
   ```

### Problem: NWTOC says "MACHINE variable not set"

**Solution:**

```bat
C:\> EDIT C:\AUTOEXEC.BAT
[Add: SET MACHINE=TS-4R]
[Save]

C:\> SET MACHINE=TS-4R
C:\> NWTOC
```

### Problem: Sync not working between AD2 and NAS

**Check sync status:**

```bash
# On NAS
cat /mnt/test/_SYNC_STATUS.txt

# Check sync log
tail -f /var/log/sync-to-ad2.log

# Force sync
sudo /root/sync-to-ad2.sh
```

**Common issues:**

1. **AD2 share not accessible:**
   ```bash
   # Test mount
   sudo mount -t cifs //192.168.1.XXX/test /mnt/ad2-test -o credentials=/root/.smbcredentials,vers=1.0
   ```

2. **Credentials incorrect:**
   ```bash
   # Check credentials file
   sudo cat /root/.smbcredentials
   # Should contain:
   #   username=admin
   #   password=xxx
   ```

3. **Firewall blocking:**
   ```bash
   # Test connectivity
   ping 192.168.1.XXX  # AD2 IP
   telnet 192.168.1.XXX 445  # SMB port
   ```

---

## Summary

After successful deployment:

1. All DOS machines have MACHINE variable set
2. All machines can access T: and X: drives
3. NWTOC pulls updates from network
4. UPDATE backs up to network
5. System file updates work safely
6. Sync between AD2 and NAS is automatic
7. DattoRMM monitors sync status

**Commands available on all machines:**

```
NWTOC      - Download updates from network
CTONW      - Upload local changes to network
UPDATE     - Backup entire C:\ to network
CHECKUPD   - Check for available updates
```

**Files automatically backed up:**

- Batch files: C:\BAT\*.BAK
- System files: C:\AUTOEXEC.SAV, C:\CONFIG.SAV
- Full backup: T:\[MACHINE]\BACKUP\

---

**Deployment Date:** __________
**Deployed By:** __________
**Machines Deployed:** ____ / ____

**End of Deployment Guide**
