1 |
brianr |
1.1 |
diff -Nur smeserver-unifi-5.6.30.ori/root/etc/e-smith/events/actions/upgrade_unifi_controller.sh smeserver-unifi-5.6.30/root/etc/e-smith/events/actions/upgrade_unifi_controller.sh |
2 |
|
|
--- smeserver-unifi-5.6.30.ori/root/etc/e-smith/events/actions/upgrade_unifi_controller.sh 2018-03-09 02:19:45.755000000 -0500 |
3 |
|
|
+++ smeserver-unifi-5.6.30/root/etc/e-smith/events/actions/upgrade_unifi_controller.sh 2018-03-09 01:51:47.721000000 -0500 |
4 |
|
|
@@ -23,7 +23,8 @@ |
5 |
|
|
# then run the script! |
6 |
|
|
|
7 |
|
|
# CONFIGURATION OPTIONS |
8 |
|
|
-UNIFI_DOWNLOAD_URL=http://dl.ubnt.com/unifi/5.0.7/UniFi.unix.zip |
9 |
|
|
+VERSION=$(/sbin/e-smith/db configuration getprop unifi VersionToInstall || echo "5.6.30") |
10 |
|
|
+UNIFI_DOWNLOAD_URL=http://dl.ubnt.com/unifi/$VERSION/UniFi.unix.zip |
11 |
|
|
UNIFI_ARCHIVE_FILENAME=UniFi.unix.zip |
12 |
|
|
UNIFI_OWNER=ubnt |
13 |
|
|
UNIFI_SERVICE=unifi |
14 |
|
|
@@ -34,6 +35,9 @@ |
15 |
|
|
|
16 |
|
|
#### SHOULDN'T HAVE TO MODIFY PAST THIS POINT #### |
17 |
|
|
|
18 |
|
|
+#today date |
19 |
|
|
+TODAY=$(date +%Y-%m-%d-%H%M%S) |
20 |
|
|
+ |
21 |
|
|
# Create progress dots function |
22 |
|
|
show_dots() { |
23 |
|
|
while ps $1 >/dev/null ; do |
24 |
|
|
@@ -63,22 +67,24 @@ |
25 |
|
|
service $UNIFI_SERVICE stop |
26 |
|
|
|
27 |
|
|
# Remove previous backup directory (if it exists) |
28 |
|
|
- if [ -d "$UNIFI_BACKUP_DIR" ]; then |
29 |
|
|
- printf "\nRemoving previous backup directory...\n" |
30 |
|
|
- rm -rf $UNIFI_BACKUP_DIR |
31 |
|
|
- fi |
32 |
|
|
+# if [ -d "$UNIFI_BACKUP_DIR" ]; then |
33 |
|
|
+# printf "\nRemoving previous backup directory...\n" |
34 |
|
|
+# rm -rf $UNIFI_BACKUP_DIR |
35 |
|
|
+# fi |
36 |
|
|
+ # remove previous backup and leave the 3 last |
37 |
|
|
+ ls -tp $UNIFI_BACKUP_DIR/ | grep -v '/$' | tail -n +3 | xargs -d '\n' -r rm -- |
38 |
|
|
|
39 |
|
|
# Move existing UniFi directory to backup location |
40 |
|
|
printf "\nMoving existing UniFi Controller directory to backup location...\n" |
41 |
|
|
- mv $UNIFI_DIR $UNIFI_BACKUP_DIR |
42 |
|
|
- |
43 |
|
|
+ mv $UNIFI_DIR "$UNIFI_BACKUP_DIR/UniFi_$TODAY" |
44 |
|
|
+ |
45 |
|
|
# Extract new version |
46 |
|
|
printf "\nExtracting downloaded software..." |
47 |
|
|
unzip -qq $TEMP_DIR/$UNIFI_ARCHIVE_FILENAME -d $UNIFI_PARENT_DIR & |
48 |
|
|
show_dots $! |
49 |
|
|
|
50 |
|
|
# Jump into the backup directory |
51 |
|
|
- cd $UNIFI_BACKUP_DIR || exit |
52 |
|
|
+ cd "$UNIFI_BACKUP_DIR/UniFi_$TODAY" || exit |
53 |
|
|
|
54 |
|
|
# Create an archive of the existing data directory |
55 |
|
|
printf "\nBacking up existing UniFi Controller data..." |
56 |
|
|
diff -Nur smeserver-unifi-5.6.30.ori/root/etc/rc.d/init.d/unifi smeserver-unifi-5.6.30/root/etc/rc.d/init.d/unifi |
57 |
|
|
--- smeserver-unifi-5.6.30.ori/root/etc/rc.d/init.d/unifi 2018-03-09 02:20:17.912000000 -0500 |
58 |
|
|
+++ smeserver-unifi-5.6.30/root/etc/rc.d/init.d/unifi 2018-03-09 01:38:21.369000000 -0500 |
59 |
|
|
@@ -15,11 +15,16 @@ |
60 |
|
|
PATH_TO_JAR=/opt/UniFi/lib/ace.jar |
61 |
|
|
MEM_LIMIT=1024M |
62 |
|
|
PID_FILE=/var/run/unifi.pid |
63 |
|
|
+USER='ubnt' |
64 |
|
|
+JSVC_EXTRA_OPTS="-user $USER"; |
65 |
|
|
+ |
66 |
|
|
+. /opt/rh/rh-mongodb34/service-environment |
67 |
|
|
+. scl_source enable $RH_MONGODB34_SCLS_ENABLED |
68 |
|
|
|
69 |
|
|
start() { |
70 |
|
|
if [ ! -f $PID_FILE ]; then |
71 |
|
|
echo -n "Starting $SERVICE_NAME: " |
72 |
|
|
- $PATH_TO_JAVA -Xmx$MEM_LIMIT -jar $PATH_TO_JAR start &> /dev/null & |
73 |
|
|
+ daemon --user=$USER $PATH_TO_JAVA -Xmx$MEM_LIMIT $JSVC_OPTS -jar $PATH_TO_JAR start &> /dev/null & |
74 |
|
|
echo $! > $PID_FILE |
75 |
|
|
echo_success |
76 |
|
|
echo |
77 |
|
|
@@ -34,7 +39,7 @@ |
78 |
|
|
if [ -f $PID_FILE ]; then |
79 |
|
|
PID=$(cat $PID_FILE); |
80 |
|
|
echo -n "Stopping $SERVICE_NAME: " |
81 |
|
|
- $PATH_TO_JAVA -jar $PATH_TO_JAR stop &> /dev/null & |
82 |
|
|
+ daemon --user=$USER $PATH_TO_JAVA $JSVC_OPTS -jar $PATH_TO_JAR stop &> /dev/null & |
83 |
|
|
rm $PID_FILE |
84 |
|
|
echo_success |
85 |
|
|
echo |