-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsst-ver-switch
executable file
·58 lines (48 loc) · 1.49 KB
/
sst-ver-switch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash
#
# Copyright (C) 2017-2025 Tactical Computing Laboratories, LLC
# All Rights Reserved
# See LICENSE in the top level directory for licensing details
#
CONFIG_FILE=~/.sst/sstsimulator.conf
#-- check to see if we have something existent
#if [ ! -f $CONFIG_FILE ]; then
# echo "SST local configuration not found: $CONFIG_FILE. Creating one."
# touch $CONFIG_FILE
#fi
#-- derive the current script version
if [ -f $CONFIG_FILE ]; then
CURRENT_VERSION=`cat $CONFIG_FILE | grep "# SST_VERSION" | awk '{print $3}'`
echo "Current version of the local SST config is: $CURRENT_VERSION"
else
CURRENT_VERSION="NULL"
echo "No current SST config loaded"
fi
#-- derive the current version of SST
SST_CMD=`which sst`
if [[ ! -n "$SST_CMD" ]]; then
echo "ERROR: cannot find the SST executable"
exit -1;
fi
SST_VERSION=`sst --version | awk '{print $3}' | tr -d '()'`
if [[ "$SST_VERSION" == "$CURRENT_VERSION" ]]; then
echo "Correct version of the local SST configuration is already loaded"
exit 0;
fi
# -- copy the current version old
if [ -f $CONFIG_FILE ]; then
if [[ "$CURRENT_VERSION" != "NULL" ]]; then
cp -f $CONFIG_FILE ~/.sst/sstsimulator.conf@$CURRENT_VERSION
rm -Rf $CONFIG_FILE
fi
fi
NEW_CONFIG="$CONFIG_FILE@$SST_VERSION"
if [ ! -f $NEW_CONFIG ]; then
echo "SST local configuration not found for verison $SST_VERSION. Creating one."
touch $CONFIG_FILE
else
echo "Copying existing config from $NEW_CONFIG"
cp -f $NEW_CONFIG $CONFIG_FILE
fi
# EOF