Standardize ASP filenames: remove underscores
Renamed 45 ASP files to follow lowercase concatenated naming convention: - Direct handlers: save_machine_direct.asp -> savemachinedirect.asp - USB files: checkin_usb.asp -> checkinusb.asp - API files: api_usb.asp -> apiusb.asp - Map files: network_map.asp -> networkmap.asp - Printer files: printer_lookup.asp -> printerlookup.asp Also: - Updated 84+ internal references across all ASP and JS files - Deleted 6 test/duplicate files (editmacine.asp, test_*.asp) - Updated production migration guide with filename changes - Added rename scripts for Linux (bash) and Windows (PowerShell)
This commit is contained in:
@@ -14,6 +14,7 @@ This guide covers all database changes made on December 10, 2025 that need to be
|
||||
3. Fix backwards Controls relationships (Equipment->PC to PC->Equipment)
|
||||
4. Propagate controller assignments to dualpath machines
|
||||
5. Sync equipment data between dualpath partners
|
||||
6. ASP filename standardization (remove underscores)
|
||||
|
||||
---
|
||||
|
||||
@@ -582,6 +583,7 @@ Pull the latest code from Gitea which includes:
|
||||
- Updated table names in all ASP files
|
||||
- New dualpath propagation functions in `includes/db_helpers.asp`
|
||||
- Updated save pages that call propagation functions
|
||||
- Renamed ASP files (underscores removed)
|
||||
|
||||
```cmd
|
||||
cd C:\inetpub\wwwroot\shopdb
|
||||
@@ -590,6 +592,58 @@ git pull origin master
|
||||
|
||||
Or copy files manually from a prepared deployment package.
|
||||
|
||||
**IMPORTANT:** After git pull, verify the old underscore files were deleted. If they still exist, remove them manually:
|
||||
|
||||
```cmd
|
||||
REM These old files should no longer exist after git pull
|
||||
REM If they do, delete them:
|
||||
del addlink_direct.asp
|
||||
del addsubnetbackend_direct.asp
|
||||
del admin_clear_cache.asp
|
||||
del api_businessunits.asp
|
||||
del api_printers.asp
|
||||
del api_shopfloor.asp
|
||||
del api_usb.asp
|
||||
del bulk_update_notification_types.asp
|
||||
del check_duplicate_printers.asp
|
||||
del check_printer_machines_count.asp
|
||||
del checkin_usb.asp
|
||||
del checkout_usb.asp
|
||||
del cleanup_duplicate_printers_execute.asp
|
||||
del displaylocation_device.asp
|
||||
del editapplication_direct.asp
|
||||
del insert_all_printer_machines.asp
|
||||
del install_printer.asp
|
||||
del machine_edit.asp
|
||||
del machine_map.asp
|
||||
del machine_map_editor.asp
|
||||
del network_devices.asp
|
||||
del network_map.asp
|
||||
del network_map_debug.asp
|
||||
del printer_installer_map.asp
|
||||
del printer_links_generator.asp
|
||||
del printer_lookup.asp
|
||||
del quickadd_application.asp
|
||||
del refresh_zabbix_cache.asp
|
||||
del save_network_device.asp
|
||||
del saveapplication_direct.asp
|
||||
del savecheckin_usb.asp
|
||||
del savecheckout_usb.asp
|
||||
del savedevice_direct.asp
|
||||
del savemachine_direct.asp
|
||||
del savemodel_direct.asp
|
||||
del savenotification_direct.asp
|
||||
del saveprinter_direct.asp
|
||||
del saveusb_direct.asp
|
||||
del savevendor_direct.asp
|
||||
del updatedevice_direct.asp
|
||||
del updatelink_direct.asp
|
||||
del updatenotification_direct.asp
|
||||
del updatepc_direct.asp
|
||||
del updatesubnet_direct.asp
|
||||
del usb_history.asp
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Step 8: Start IIS
|
||||
@@ -657,12 +711,15 @@ iisreset /start
|
||||
| Category | Change | Script |
|
||||
|----------|--------|--------|
|
||||
| Naming | Rename 6 tables (snake_case to camelCase) | naming_convention_fix/*.sql |
|
||||
| Naming | Rename 17 columns in compliance tables | naming_convention_fix/07_*.sql |
|
||||
| Naming | Recreate 9 views with new table names | naming_convention_fix/04_*.sql |
|
||||
| Naming | Rename 45 ASP files (remove underscores) | naming_convention_fix/09_*.sh |
|
||||
| Relationships | Fix backwards Controls relationships | fix_dualpath_controller_relationships.sql |
|
||||
| Relationships | Propagate controllers to dualpath machines | fix_dualpath_controller_relationships.sql |
|
||||
| Data Sync | Sync equipment data between dualpath pairs | sync_dualpath_equipment_data.sql |
|
||||
| ASP Files | Update table references in 10 ASP files | git pull |
|
||||
| ASP Files | Update table references in 10+ ASP files | git pull |
|
||||
| ASP Files | Add dualpath propagation functions | git pull |
|
||||
| ASP Files | Delete 6 test/duplicate files | git pull |
|
||||
|
||||
---
|
||||
|
||||
@@ -674,6 +731,9 @@ All scripts are in `/sql/` directory:
|
||||
|--------|---------|
|
||||
| `naming_convention_fix/03_rename_tables.sql` | Table renames |
|
||||
| `naming_convention_fix/04_drop_and_recreate_views.sql` | View recreation |
|
||||
| `naming_convention_fix/07_fix_compliance_columns.sql` | Compliance column renames |
|
||||
| `naming_convention_fix/09_rename_asp_files.sh` | ASP filename renames (Linux) |
|
||||
| `naming_convention_fix/09_rename_asp_files.ps1` | ASP filename renames (Windows) |
|
||||
| `fix_dualpath_controller_relationships.sql` | Fix relationship direction + propagate |
|
||||
| `sync_dualpath_equipment_data.sql` | Sync equipment data between dualpath pairs |
|
||||
|
||||
|
||||
93
sql/naming_convention_fix/08_asp_filename_renames.md
Normal file
93
sql/naming_convention_fix/08_asp_filename_renames.md
Normal file
@@ -0,0 +1,93 @@
|
||||
# ASP Filename Rename Plan
|
||||
|
||||
## Naming Convention
|
||||
- All lowercase
|
||||
- No underscores (use concatenated words like `displaymachine.asp`)
|
||||
- Pattern: `[action][entity].asp` or `[action][entity]direct.asp` for form handlers
|
||||
|
||||
## Files to Rename
|
||||
|
||||
### Remove underscores from direct handlers
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| addlink_direct.asp | addlinkdirect.asp |
|
||||
| addsubnetbackend_direct.asp | addsubnetbackenddirect.asp |
|
||||
| editapplication_direct.asp | editapplicationdirect.asp |
|
||||
| saveapplication_direct.asp | saveapplicationdirect.asp |
|
||||
| savedevice_direct.asp | savedevicedirect.asp |
|
||||
| savemachine_direct.asp | savemachinedirect.asp |
|
||||
| savemodel_direct.asp | savemodeldirect.asp |
|
||||
| save_network_device.asp | savenetworkdevice.asp |
|
||||
| savenotification_direct.asp | savenotificationdirect.asp |
|
||||
| saveprinter_direct.asp | saveprinterdirect.asp |
|
||||
| saveusb_direct.asp | saveusbdirect.asp |
|
||||
| savevendor_direct.asp | savevendordirect.asp |
|
||||
| updatedevice_direct.asp | updatedevicedirect.asp |
|
||||
| updatelink_direct.asp | updatelinkdirect.asp |
|
||||
| updatenotification_direct.asp | updatenotificationdirect.asp |
|
||||
| updatepc_direct.asp | updatepcdirect.asp |
|
||||
| updatesubnet_direct.asp | updatesubnetdirect.asp |
|
||||
|
||||
### Remove underscores from USB files
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| checkin_usb.asp | checkinusb.asp |
|
||||
| checkout_usb.asp | checkoutusb.asp |
|
||||
| savecheckin_usb.asp | savecheckinusb.asp |
|
||||
| savecheckout_usb.asp | savecheckoutusb.asp |
|
||||
| usb_history.asp | usbhistory.asp |
|
||||
|
||||
### Remove underscores from API files
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| api_businessunits.asp | apibusinessunits.asp |
|
||||
| api_printers.asp | apiprinters.asp |
|
||||
| api_shopfloor.asp | apishopfloor.asp |
|
||||
| api_usb.asp | apiusb.asp |
|
||||
|
||||
### Remove underscores from machine/map files
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| machine_edit.asp | machineedit.asp |
|
||||
| machine_map.asp | machinemap.asp |
|
||||
| machine_map_editor.asp | machinemapeditor.asp |
|
||||
| network_devices.asp | networkdevices.asp |
|
||||
| network_map.asp | networkmap.asp |
|
||||
| network_map_debug.asp | networkmapdebug.asp |
|
||||
|
||||
### Remove underscores from printer files
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| check_duplicate_printers.asp | checkduplicateprinters.asp |
|
||||
| check_printer_machines_count.asp | checkprintermachinescount.asp |
|
||||
| cleanup_duplicate_printers_execute.asp | cleanupduplicateprintersexecute.asp |
|
||||
| insert_all_printer_machines.asp | insertallprintermachines.asp |
|
||||
| install_printer.asp | installprinter.asp |
|
||||
| printer_installer_map.asp | printerinstallermap.asp |
|
||||
| printer_links_generator.asp | printerlinksgenerator.asp |
|
||||
| printer_lookup.asp | printerlookup.asp |
|
||||
|
||||
### Remove underscores from other files
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| admin_clear_cache.asp | adminclearcache.asp |
|
||||
| bulk_update_notification_types.asp | bulkupdatenotificationtypes.asp |
|
||||
| displaylocation_device.asp | displaylocationdevice.asp |
|
||||
| quickadd_application.asp | quickaddapplication.asp |
|
||||
| refresh_zabbix_cache.asp | refreshzabbixcache.asp |
|
||||
|
||||
### Fix typo
|
||||
| Old Name | New Name |
|
||||
|----------|----------|
|
||||
| editmacine.asp | (DELETE - duplicate of editmachine.asp) |
|
||||
|
||||
### Test files to DELETE (not rename)
|
||||
- editmachine_test.asp
|
||||
- test_asp.asp
|
||||
- test_db.asp
|
||||
- test_switch_query.asp
|
||||
- test_with_includes.asp
|
||||
|
||||
## Total Changes
|
||||
- **49 files to rename**
|
||||
- **6 files to delete**
|
||||
200
sql/naming_convention_fix/09_rename_asp_files.ps1
Normal file
200
sql/naming_convention_fix/09_rename_asp_files.ps1
Normal file
@@ -0,0 +1,200 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Renames ASP files to remove underscores and updates all internal references.
|
||||
|
||||
.DESCRIPTION
|
||||
This script:
|
||||
1. Renames ASP files from snake_case to concatenated lowercase
|
||||
2. Updates all references in ASP, JS, and include files
|
||||
3. Deletes test files
|
||||
|
||||
.PARAMETER Execute
|
||||
Actually perform the renames. Without this, runs in dry-run mode.
|
||||
|
||||
.EXAMPLE
|
||||
.\09_rename_asp_files.ps1 # Dry run - shows what would change
|
||||
.\09_rename_asp_files.ps1 -Execute # Actually performs the renames
|
||||
#>
|
||||
|
||||
param(
|
||||
[switch]$Execute
|
||||
)
|
||||
|
||||
$shopdbPath = Split-Path -Parent (Split-Path -Parent $PSScriptRoot)
|
||||
|
||||
# Define rename mappings (old -> new)
|
||||
$renames = @{
|
||||
# Direct handlers
|
||||
"addlink_direct.asp" = "addlinkdirect.asp"
|
||||
"addsubnetbackend_direct.asp" = "addsubnetbackenddirect.asp"
|
||||
"editapplication_direct.asp" = "editapplicationdirect.asp"
|
||||
"saveapplication_direct.asp" = "saveapplicationdirect.asp"
|
||||
"savedevice_direct.asp" = "savedevicedirect.asp"
|
||||
"savemachine_direct.asp" = "savemachinedirect.asp"
|
||||
"savemodel_direct.asp" = "savemodeldirect.asp"
|
||||
"save_network_device.asp" = "savenetworkdevice.asp"
|
||||
"savenotification_direct.asp" = "savenotificationdirect.asp"
|
||||
"saveprinter_direct.asp" = "saveprinterdirect.asp"
|
||||
"saveusb_direct.asp" = "saveusbdirect.asp"
|
||||
"savevendor_direct.asp" = "savevendordirect.asp"
|
||||
"updatedevice_direct.asp" = "updatedevicedirect.asp"
|
||||
"updatelink_direct.asp" = "updatelinkdirect.asp"
|
||||
"updatenotification_direct.asp" = "updatenotificationdirect.asp"
|
||||
"updatepc_direct.asp" = "updatepcdirect.asp"
|
||||
"updatesubnet_direct.asp" = "updatesubnetdirect.asp"
|
||||
|
||||
# USB files
|
||||
"checkin_usb.asp" = "checkinusb.asp"
|
||||
"checkout_usb.asp" = "checkoutusb.asp"
|
||||
"savecheckin_usb.asp" = "savecheckinusb.asp"
|
||||
"savecheckout_usb.asp" = "savecheckoutusb.asp"
|
||||
"usb_history.asp" = "usbhistory.asp"
|
||||
|
||||
# API files
|
||||
"api_businessunits.asp" = "apibusinessunits.asp"
|
||||
"api_printers.asp" = "apiprinters.asp"
|
||||
"api_shopfloor.asp" = "apishopfloor.asp"
|
||||
"api_usb.asp" = "apiusb.asp"
|
||||
|
||||
# Machine/map files
|
||||
"machine_edit.asp" = "machineedit.asp"
|
||||
"machine_map.asp" = "machinemap.asp"
|
||||
"machine_map_editor.asp" = "machinemapeditor.asp"
|
||||
"network_devices.asp" = "networkdevices.asp"
|
||||
"network_map.asp" = "networkmap.asp"
|
||||
"network_map_debug.asp" = "networkmapdebug.asp"
|
||||
|
||||
# Printer files
|
||||
"check_duplicate_printers.asp" = "checkduplicateprinters.asp"
|
||||
"check_printer_machines_count.asp" = "checkprintermachinescount.asp"
|
||||
"cleanup_duplicate_printers_execute.asp" = "cleanupduplicateprintersexecute.asp"
|
||||
"insert_all_printer_machines.asp" = "insertallprintermachines.asp"
|
||||
"install_printer.asp" = "installprinter.asp"
|
||||
"printer_installer_map.asp" = "printerinstallermap.asp"
|
||||
"printer_links_generator.asp" = "printerlinksgenerator.asp"
|
||||
"printer_lookup.asp" = "printerlookup.asp"
|
||||
|
||||
# Other files
|
||||
"admin_clear_cache.asp" = "adminclearcache.asp"
|
||||
"bulk_update_notification_types.asp" = "bulkupdatenotificationtypes.asp"
|
||||
"displaylocation_device.asp" = "displaylocationdevice.asp"
|
||||
"quickadd_application.asp" = "quickaddapplication.asp"
|
||||
"refresh_zabbix_cache.asp" = "refreshzabbixcache.asp"
|
||||
}
|
||||
|
||||
# Files to delete
|
||||
$deleteFiles = @(
|
||||
"editmacine.asp"
|
||||
"editmachine_test.asp"
|
||||
"test_asp.asp"
|
||||
"test_db.asp"
|
||||
"test_switch_query.asp"
|
||||
"test_with_includes.asp"
|
||||
)
|
||||
|
||||
Write-Host "ASP File Rename Script" -ForegroundColor Cyan
|
||||
Write-Host "======================" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
if (-not $Execute) {
|
||||
Write-Host "DRY RUN MODE - No changes will be made" -ForegroundColor Yellow
|
||||
Write-Host "Run with -Execute to apply changes" -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
# Get all files to search for references
|
||||
$searchFiles = @()
|
||||
$searchFiles += Get-ChildItem -Path $shopdbPath -Filter "*.asp" -File
|
||||
$searchFiles += Get-ChildItem -Path "$shopdbPath\includes" -Filter "*.asp" -File -ErrorAction SilentlyContinue
|
||||
$searchFiles += Get-ChildItem -Path "$shopdbPath\js" -Filter "*.js" -File -ErrorAction SilentlyContinue
|
||||
|
||||
Write-Host "Found $($searchFiles.Count) files to search for references" -ForegroundColor Gray
|
||||
Write-Host ""
|
||||
|
||||
# Step 1: Update all references in files
|
||||
Write-Host "STEP 1: Updating references in files..." -ForegroundColor Green
|
||||
$totalReplacements = 0
|
||||
|
||||
foreach ($file in $searchFiles) {
|
||||
$content = Get-Content -Path $file.FullName -Raw -ErrorAction SilentlyContinue
|
||||
if (-not $content) { continue }
|
||||
|
||||
$originalContent = $content
|
||||
$fileChanged = $false
|
||||
|
||||
foreach ($oldName in $renames.Keys) {
|
||||
$newName = $renames[$oldName]
|
||||
if ($content -match [regex]::Escape($oldName)) {
|
||||
$content = $content -replace [regex]::Escape($oldName), $newName
|
||||
$fileChanged = $true
|
||||
$totalReplacements++
|
||||
}
|
||||
}
|
||||
|
||||
if ($fileChanged) {
|
||||
Write-Host " Updated: $($file.Name)" -ForegroundColor White
|
||||
if ($Execute) {
|
||||
Set-Content -Path $file.FullName -Value $content -NoNewline
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " Total replacements: $totalReplacements" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Step 2: Rename the files
|
||||
Write-Host "STEP 2: Renaming files..." -ForegroundColor Green
|
||||
$renamedCount = 0
|
||||
|
||||
foreach ($oldName in $renames.Keys) {
|
||||
$newName = $renames[$oldName]
|
||||
$oldPath = Join-Path $shopdbPath $oldName
|
||||
$newPath = Join-Path $shopdbPath $newName
|
||||
|
||||
if (Test-Path $oldPath) {
|
||||
Write-Host " $oldName -> $newName" -ForegroundColor White
|
||||
if ($Execute) {
|
||||
Rename-Item -Path $oldPath -NewName $newName
|
||||
}
|
||||
$renamedCount++
|
||||
} else {
|
||||
Write-Host " SKIP: $oldName (not found)" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " Files to rename: $renamedCount" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Step 3: Delete test files
|
||||
Write-Host "STEP 3: Deleting test/duplicate files..." -ForegroundColor Green
|
||||
$deletedCount = 0
|
||||
|
||||
foreach ($fileName in $deleteFiles) {
|
||||
$filePath = Join-Path $shopdbPath $fileName
|
||||
if (Test-Path $filePath) {
|
||||
Write-Host " DELETE: $fileName" -ForegroundColor Red
|
||||
if ($Execute) {
|
||||
Remove-Item -Path $filePath -Force
|
||||
}
|
||||
$deletedCount++
|
||||
} else {
|
||||
Write-Host " SKIP: $fileName (not found)" -ForegroundColor DarkGray
|
||||
}
|
||||
}
|
||||
|
||||
Write-Host " Files to delete: $deletedCount" -ForegroundColor Cyan
|
||||
Write-Host ""
|
||||
|
||||
# Summary
|
||||
Write-Host "SUMMARY" -ForegroundColor Cyan
|
||||
Write-Host "=======" -ForegroundColor Cyan
|
||||
Write-Host " References updated: $totalReplacements"
|
||||
Write-Host " Files renamed: $renamedCount"
|
||||
Write-Host " Files deleted: $deletedCount"
|
||||
Write-Host ""
|
||||
|
||||
if (-not $Execute) {
|
||||
Write-Host "This was a DRY RUN. Run with -Execute to apply changes." -ForegroundColor Yellow
|
||||
} else {
|
||||
Write-Host "Changes applied successfully!" -ForegroundColor Green
|
||||
}
|
||||
177
sql/naming_convention_fix/09_rename_asp_files.sh
Executable file
177
sql/naming_convention_fix/09_rename_asp_files.sh
Executable file
@@ -0,0 +1,177 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Renames ASP files to remove underscores and updates all internal references.
|
||||
#
|
||||
# Usage:
|
||||
# ./09_rename_asp_files.sh # Dry run - shows what would change
|
||||
# ./09_rename_asp_files.sh --execute # Actually performs the renames
|
||||
#
|
||||
|
||||
SHOPDB_PATH="/home/camp/projects/windows/shopdb"
|
||||
EXECUTE=false
|
||||
|
||||
if [ "$1" == "--execute" ]; then
|
||||
EXECUTE=true
|
||||
fi
|
||||
|
||||
echo "ASP File Rename Script"
|
||||
echo "======================"
|
||||
echo ""
|
||||
|
||||
if [ "$EXECUTE" != "true" ]; then
|
||||
echo "DRY RUN MODE - No changes will be made"
|
||||
echo "Run with --execute to apply changes"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Define rename mappings
|
||||
declare -A RENAMES=(
|
||||
# Direct handlers
|
||||
["addlink_direct.asp"]="addlinkdirect.asp"
|
||||
["addsubnetbackend_direct.asp"]="addsubnetbackenddirect.asp"
|
||||
["editapplication_direct.asp"]="editapplicationdirect.asp"
|
||||
["saveapplication_direct.asp"]="saveapplicationdirect.asp"
|
||||
["savedevice_direct.asp"]="savedevicedirect.asp"
|
||||
["savemachine_direct.asp"]="savemachinedirect.asp"
|
||||
["savemodel_direct.asp"]="savemodeldirect.asp"
|
||||
["save_network_device.asp"]="savenetworkdevice.asp"
|
||||
["savenotification_direct.asp"]="savenotificationdirect.asp"
|
||||
["saveprinter_direct.asp"]="saveprinterdirect.asp"
|
||||
["saveusb_direct.asp"]="saveusbdirect.asp"
|
||||
["savevendor_direct.asp"]="savevendordirect.asp"
|
||||
["updatedevice_direct.asp"]="updatedevicedirect.asp"
|
||||
["updatelink_direct.asp"]="updatelinkdirect.asp"
|
||||
["updatenotification_direct.asp"]="updatenotificationdirect.asp"
|
||||
["updatepc_direct.asp"]="updatepcdirect.asp"
|
||||
["updatesubnet_direct.asp"]="updatesubnetdirect.asp"
|
||||
|
||||
# USB files
|
||||
["checkin_usb.asp"]="checkinusb.asp"
|
||||
["checkout_usb.asp"]="checkoutusb.asp"
|
||||
["savecheckin_usb.asp"]="savecheckinusb.asp"
|
||||
["savecheckout_usb.asp"]="savecheckoutusb.asp"
|
||||
["usb_history.asp"]="usbhistory.asp"
|
||||
|
||||
# API files
|
||||
["api_businessunits.asp"]="apibusinessunits.asp"
|
||||
["api_printers.asp"]="apiprinters.asp"
|
||||
["api_shopfloor.asp"]="apishopfloor.asp"
|
||||
["api_usb.asp"]="apiusb.asp"
|
||||
|
||||
# Machine/map files
|
||||
["machine_edit.asp"]="machineedit.asp"
|
||||
["machine_map.asp"]="machinemap.asp"
|
||||
["machine_map_editor.asp"]="machinemapeditor.asp"
|
||||
["network_devices.asp"]="networkdevices.asp"
|
||||
["network_map.asp"]="networkmap.asp"
|
||||
["network_map_debug.asp"]="networkmapdebug.asp"
|
||||
|
||||
# Printer files
|
||||
["check_duplicate_printers.asp"]="checkduplicateprinters.asp"
|
||||
["check_printer_machines_count.asp"]="checkprintermachinescount.asp"
|
||||
["cleanup_duplicate_printers_execute.asp"]="cleanupduplicateprintersexecute.asp"
|
||||
["insert_all_printer_machines.asp"]="insertallprintermachines.asp"
|
||||
["install_printer.asp"]="installprinter.asp"
|
||||
["printer_installer_map.asp"]="printerinstallermap.asp"
|
||||
["printer_links_generator.asp"]="printerlinksgenerator.asp"
|
||||
["printer_lookup.asp"]="printerlookup.asp"
|
||||
|
||||
# Other files
|
||||
["admin_clear_cache.asp"]="adminclearcache.asp"
|
||||
["bulk_update_notification_types.asp"]="bulkupdatenotificationtypes.asp"
|
||||
["displaylocation_device.asp"]="displaylocationdevice.asp"
|
||||
["quickadd_application.asp"]="quickaddapplication.asp"
|
||||
["refresh_zabbix_cache.asp"]="refreshzabbixcache.asp"
|
||||
)
|
||||
|
||||
# Files to delete
|
||||
DELETE_FILES=(
|
||||
"editmacine.asp"
|
||||
"editmachine_test.asp"
|
||||
"test_asp.asp"
|
||||
"test_db.asp"
|
||||
"test_switch_query.asp"
|
||||
"test_with_includes.asp"
|
||||
)
|
||||
|
||||
# Step 1: Update all references in files
|
||||
echo "STEP 1: Updating references in files..."
|
||||
TOTAL_REPLACEMENTS=0
|
||||
|
||||
for OLD_NAME in "${!RENAMES[@]}"; do
|
||||
NEW_NAME="${RENAMES[$OLD_NAME]}"
|
||||
|
||||
# Find files containing the old name
|
||||
FILES_WITH_REF=$(grep -rl "$OLD_NAME" "$SHOPDB_PATH"/*.asp "$SHOPDB_PATH"/includes/*.asp "$SHOPDB_PATH"/js/*.js 2>/dev/null)
|
||||
|
||||
if [ -n "$FILES_WITH_REF" ]; then
|
||||
for FILE in $FILES_WITH_REF; do
|
||||
echo " Updating $OLD_NAME -> $NEW_NAME in $(basename $FILE)"
|
||||
if [ "$EXECUTE" == "true" ]; then
|
||||
sed -i "s/$OLD_NAME/$NEW_NAME/g" "$FILE"
|
||||
fi
|
||||
TOTAL_REPLACEMENTS=$((TOTAL_REPLACEMENTS + 1))
|
||||
done
|
||||
fi
|
||||
done
|
||||
|
||||
echo " Total file updates: $TOTAL_REPLACEMENTS"
|
||||
echo ""
|
||||
|
||||
# Step 2: Rename the files
|
||||
echo "STEP 2: Renaming files..."
|
||||
RENAMED_COUNT=0
|
||||
|
||||
for OLD_NAME in "${!RENAMES[@]}"; do
|
||||
NEW_NAME="${RENAMES[$OLD_NAME]}"
|
||||
OLD_PATH="$SHOPDB_PATH/$OLD_NAME"
|
||||
NEW_PATH="$SHOPDB_PATH/$NEW_NAME"
|
||||
|
||||
if [ -f "$OLD_PATH" ]; then
|
||||
echo " $OLD_NAME -> $NEW_NAME"
|
||||
if [ "$EXECUTE" == "true" ]; then
|
||||
mv "$OLD_PATH" "$NEW_PATH"
|
||||
fi
|
||||
RENAMED_COUNT=$((RENAMED_COUNT + 1))
|
||||
else
|
||||
echo " SKIP: $OLD_NAME (not found)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " Files to rename: $RENAMED_COUNT"
|
||||
echo ""
|
||||
|
||||
# Step 3: Delete test files
|
||||
echo "STEP 3: Deleting test/duplicate files..."
|
||||
DELETED_COUNT=0
|
||||
|
||||
for FILE_NAME in "${DELETE_FILES[@]}"; do
|
||||
FILE_PATH="$SHOPDB_PATH/$FILE_NAME"
|
||||
|
||||
if [ -f "$FILE_PATH" ]; then
|
||||
echo " DELETE: $FILE_NAME"
|
||||
if [ "$EXECUTE" == "true" ]; then
|
||||
rm -f "$FILE_PATH"
|
||||
fi
|
||||
DELETED_COUNT=$((DELETED_COUNT + 1))
|
||||
else
|
||||
echo " SKIP: $FILE_NAME (not found)"
|
||||
fi
|
||||
done
|
||||
|
||||
echo " Files to delete: $DELETED_COUNT"
|
||||
echo ""
|
||||
|
||||
# Summary
|
||||
echo "SUMMARY"
|
||||
echo "======="
|
||||
echo " Files updated: $TOTAL_REPLACEMENTS"
|
||||
echo " Files renamed: $RENAMED_COUNT"
|
||||
echo " Files deleted: $DELETED_COUNT"
|
||||
echo ""
|
||||
|
||||
if [ "$EXECUTE" != "true" ]; then
|
||||
echo "This was a DRY RUN. Run with --execute to apply changes."
|
||||
else
|
||||
echo "Changes applied successfully!"
|
||||
fi
|
||||
Reference in New Issue
Block a user