Skip to content

Commit

Permalink
Move sanity checks to specific commands
Browse files Browse the repository at this point in the history
  • Loading branch information
keenanlang committed Jan 2, 2024
1 parent 05e1327 commit b8f8fc5
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 29 deletions.
29 changes: 29 additions & 0 deletions iocBoot/iocxxx/softioc/commands/_info.pm
Original file line number Diff line number Diff line change
Expand Up @@ -193,4 +193,33 @@ sub get_port()
return $port_to_use;
}

sub sanity_check()
{
#######################
# Sanity Checks #
#######################


if (! -d $ENV{IOC_STARTUP_DIR})
{
print("Error: Starting directory ($ENV{IOC_STARTUP_DIR}) doesn't exist.\n");
print("IOC_STARTUP_DIR in $FindBin::RealScript needs to be corrected.\n");
die;
}

if (! -f $ENV{IOC_BIN_PATH})
{
print("Error: No IOC executable at $ENV{IOC_BIN_PATH}\n");
print("IOC_BIN_PATH in $FindBin::RealScript needs to be corrected.\n");
die;
}

if (! -f $ENV{IOC_STARTUP_FILE_PATH})
{
print("Error: No IOC startup script at $ENV{IOC_STARTUP_FILE_PATH}\n");
print("IOC_STARTUP_FILE_PATH in $FindBin::RealScript needs to be corrected.\n");
return;
}
}

1;
1 change: 1 addition & 0 deletions iocBoot/iocxxx/softioc/commands/run.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ sub _local
elsif (_info::has_remote()) { print("IOC set up for remote commands\n"); }
else
{
_info::sanity_check();
print("Starting $IOC_NAME\n");

my $currdir = getcwd();
Expand Down
1 change: 1 addition & 0 deletions iocBoot/iocxxx/softioc/commands/start.pm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ sub _local()
elsif (_info::has_remote()) { _info::send_cmd("COMMAND", "start"); }
else
{
_info::sanity_check();
print ("Starting $IOC_NAME\n");

my $prefix = _info::procserv("CONSOLE", "PREFIX");
Expand Down
29 changes: 0 additions & 29 deletions iocBoot/iocxxx/softioc/xxx.pl
Original file line number Diff line number Diff line change
Expand Up @@ -95,46 +95,17 @@ BEGIN

#####################################################################


my $GET_SCREEN_PID=1;


#####################################################################

#######################
# Sanity Checks #
#######################


if (! -d $ENV{IOC_STARTUP_DIR})
{
print("Error: Starting directory ($ENV{IOC_STARTUP_DIR}) doesn't exist.\n");
print("IOC_STARTUP_DIR in $FindBin::RealScript needs to be corrected.\n");
die;
}

if (! -d $ENV{IOC_COMMAND_DIR})
{
print("Error: IOC command directory ($ENV{IOC_COMMAND_DIR}) doesn't exist.\n");
print("IOC_COMMAND_DIR in $FindBin::RealScript needs to be corrected.\n");
die;
}

if (! -f $ENV{IOC_BIN_PATH})
{
print("Error: No IOC executable at $ENV{IOC_BIN_PATH}\n");
print("IOC_BIN_PATH in $FindBin::RealScript needs to be corrected.\n");
die;
}

if (! -f $ENV{IOC_STARTUP_FILE_PATH})
{
print("Error: No IOC startup script at $ENV{IOC_STARTUP_FILE_PATH}\n");
print("IOC_STARTUP_FILE_PATH in $FindBin::RealScript needs to be corrected.\n");
return;
}


#####################
# Parse Input #
#####################
Expand Down

0 comments on commit b8f8fc5

Please sign in to comment.