Skip to content

Commit

Permalink
Adding installation script
Browse files Browse the repository at this point in the history
  • Loading branch information
geethapinnaka committed Oct 22, 2021
1 parent 0946657 commit ce68939
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 2 deletions.
18 changes: 18 additions & 0 deletions nspepi/check_invalid_config
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ $ENV{PATH} = '/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin'.$ENV

use File::Basename;

# checking if python and ply are present
# Output would be /var/python/bin/python2 if python2 is
# present, otherwise output would be empty string.
my $python_version_string = `which python2 2> /dev/null`;
if ($python_version_string eq "") {
# Python2 is not installed
print "\nAs python2 is not present, we can't check for an invalid configuration\n";
exit;
}

my $python_module_list = `python2 -m pip freeze 2> /dev/null`;
if (!($python_module_list =~ m/\bply==/)) {
# ply is not present
print "\nAs required module PLY is not present, we can't check for an invalid configuration\n";
exit;
}


my $number_args = $#ARGV + 1;
if ($number_args != 1) {
print "Usage: check_invalid_config <ns_config_file>\n";
Expand Down
17 changes: 17 additions & 0 deletions nspepi/nspepi
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,22 @@
# Use of this software is governed by the license terms, if any,
# which accompany or are included with this software.

# Checking if python and PLY are present
# Output would be /var/python/bin/python2 if python2 is
# present, otherwise output would be empty string.
python_version_string=$(which python2 2> /dev/null)
if [[ $python_version_string = "" ]]
then
echo "As python2 is not present, we can't run the NSPEPI tool"
exit
fi

python_module_list=$(python2 -m pip freeze 2> /dev/null)
if ! grep -q "\bply==" <<< $python_module_list
then
echo "As required module PLY is not present, we can't run the NSPEPI tool"
exit
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
exec $DIR/nspepi2/nspepi_main.py "$@"
88 changes: 88 additions & 0 deletions nspepi/nspepi_install_script
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#!/usr/bin/env bash

# Copyright 2021 Citrix Systems, Inc. All rights reserved.
# Use of this software is governed by the license terms, if any,
# which accompany or are included with this software.

# Following files should have executable permission
declare -a file_list_550=("nspepi"
"check_invalid_config"
"nspepi2/nspepi_main.py"
"nspepi2/config_check_main.py"
"nspepi2/nspepi_helper")

declare -a file_list_to_copy=("nspepi"
"check_invalid_config"
"nspepi_install_script")
NSPEPI2_DIR_TO_COPY="nspepi2"

NSPEPI_DIR="/netscaler"
NSPEPI_BACKUP_DIR="/var/nspepi_backup"
NSBEFORE_FILE="/nsconfig/nsbefore.sh"
INSTALL_SCRIPT_NAME="nspepi_install_script"
INSTALL_SCRIPT_BOOTUP_LOG="/var/log/nspepi_install_script_bootup.log"
BOOTUP_OPTION="bootup"

if [[ $# -eq 0 ]]; then
# If no arguments are present, then consider as initial setup
mkdir -p $NSPEPI_BACKUP_DIR

# copy the files downloaded to NSPEPI_BACKUP_DIR
echo "Copying the files to $NSPEPI_BACKUP_DIR as a backup"
for file in "${file_list_to_copy[@]}"; do
file_name="$NSPEPI_DIR/$file"
if [[ ! -f "$file_name" ]]; then
echo -e "$file_name file is missing\nInstallation failed"
exit
fi
cp $file_name $NSPEPI_BACKUP_DIR
done
# copy nspepi2 directory
nspepi2_full_path="$NSPEPI_DIR/$NSPEPI2_DIR_TO_COPY"
if [[ ! -d "$nspepi2_full_path" ]]; then
echo -e "$nspepi2_full_path directory is missing\nInstallation failed"
exit
fi
cp -r $nspepi2_full_path $NSPEPI_BACKUP_DIR

# Append the command to trigger nspepi_install_script to nsbefore.sh if it is not present
# This is required for not losing the nspepi files downloaded from GitHub during ADC reboot
if [[ ( ! -f "$NSBEFORE_FILE" ) || ( $(grep -c "$INSTALL_SCRIPT_NAME" "$NSBEFORE_FILE") -eq 0 ) ]]; then
echo "bash $NSPEPI_BACKUP_DIR/$INSTALL_SCRIPT_NAME $BOOTUP_OPTION \&> $INSTALL_SCRIPT_BOOTUP_LOG" >> $NSBEFORE_FILE
fi
elif [[ $1 == $BOOTUP_OPTION ]]; then
# Bootup
# Copy the files from backup NSPEPI_BACKUP_DIR to NSPEPI_DIR
echo "Copying the files from $NSPEPI_BACKUP_DIR to $NSPEPI_DIR"
for file in "${file_list_to_copy[@]}"; do
file_name="$NSPEPI_BACKUP_DIR/$file"
if [[ ! -f "$file_name" ]]; then
echo -e "$file_name backup file is missing\nInstallation failed"
exit
fi
cp $file_name $NSPEPI_DIR
done
# copy nspepi2 directory
nspepi2_full_path="$NSPEPI_BACKUP_DIR/$NSPEPI2_DIR_TO_COPY"
if [[ ! -d "$nspepi2_full_path" ]]; then
echo -e "$nspepi2_full_path directory is missing\nInstallation failed"
exit
fi
cp -r $nspepi2_full_path $NSPEPI_DIR
else
# Invalid argument
echo -e "Invalid command line argument\nInstallation failed"
exit
fi

# Adjust permissions
for file in "${file_list_550[@]}"; do
file_name="$NSPEPI_DIR/$file"
if [[ ! -f "$file_name" ]]; then
echo -e "$file_name file is missing\nInstallation failed"
exit
fi
chmod 550 $file_name
done

echo "Installation successful"
19 changes: 17 additions & 2 deletions nspepi/validation-conversion-script.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,14 @@ The following tools help with the conversion:
- Validation tool for detecting removed deprecated features and functionalities in Citrix ADC version 13.1.
- NSPEPI tool for converting deprecated commands/features to non-deprecated commands/features.

**Note:** Both the validation tool and the NSPEPI tool can be used only with Citrix ADC release version 12.1 or later.

For using the conversion tools, copy the files from here to your Citrix ADC appliance as per the instructions:

1. Clone the repo `https://github.com/citrix/ADC-scripts.git` and goto `ADC-scripts/nspepi` directory.
2. Copy `nspepi` and `check_invalid_config` files to the `/netscaler` path in Citrix ADC.
2. Copy `nspepi_install_script`, `nspepi`, and `check_invalid_config` files to the `/netscaler` path in Citrix ADC.
3. Copy all files under the `nspepi2` directory to the `/netscaler/nspepi2` path in Citrix ADC.
4. After copying files to Citrix ADC, change your directory to `/netscaler` and then run the `bash nspepi_install_script` command.

## Pre-validation tool for removed or deprecated features in Citrix ADC version 13.1

Expand Down Expand Up @@ -72,7 +75,7 @@ The following is an example when the configuration file does not contain any dep

The `NSPEPI` tool helps in converting the deprecated commands or features to the Citrix recommended alternatives.

## Running the NSPEPI tool
### Running the NSPEPI tool

This tool needs to be run from the command line of the shell (you should type the `shell` command on the Citrix ADC CLI).

Expand All @@ -91,6 +94,18 @@ Parameters:

The NSPEPI tool does not modify the input file. Instead, it generates two files with prefixes `new_` and `warn_` and they are put into the same directory as where the input configuration file is present. The file with the `new_ prefix` contains the converted configuration. And the file with `warn_ prefix` contains the warnings and errors. If there are any warnings or errors that got generated in the warn file, the errors must be fixed manually as part of the conversion process. Once converted, you must test the file in a test environment and then use it in the production environment to replace the actual `ns.conf` config file. After testing, you must reboot the appliance using the newly converted `ns.conf` config file.

### Best Practices:
- You must run the NSPEPI tool before upgrading to Citrix ADC release version 13.1.
- The NSPEPI tool must be run on Citrix ADC release version 12.1 or 13.0.
- For each different configuration that you need to convert:
- Run this tool on your configuration in your existing system older than 13.1 version and do any manual changes to the output that are required.
- Install the converted configuration on a suitable test system running on your existing Citrix ADC release version prior to 13.1 release.
- Perform a thorough regression testing.
- Move the configuration into production as per your normal configuration upgrade processes.
- Run in production for a sufficient time to ensure that the configuration is working correctly on real traffic.
- Upgrade to Citrix ADC version 13.1 using this configuration on a suitable schedule.

### Examples:
Following are a few examples of running the NSPEPI tool from the command line interface:

Example output for –e parameter:
Expand Down

0 comments on commit ce68939

Please sign in to comment.