forked from iiab/iiab-admin-console
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cp-menus-OBSOLETE
executable file
·85 lines (61 loc) · 2.54 KB
/
cp-menus-OBSOLETE
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/bin/bash
WWWROOT=/var/www/html
# maintain backwards compatibility
if [ -f /etc/xsce/xsce.env ]; then
source /etc/xsce/xsce.env
fi
if [ -f /etc/iiab/iiab.env ]; then
source /etc/iiab/iiab.env
fi
MENU_DEF_DIR=$WWWROOT/js-menu/menu-defs
# Install menu files from repo if this is the first time
if [ -z "$(ls -A $MENU_DEF_DIR)" ]; then
echo "Empty"
else
echo "Not Empty"
fi
# actions
wget //github.com/tim-moody/js-menu-files/archive/master.zip (or actual repo)
or just clone iiab-share/js-menu-files
git clone https://github.com/tim-moody/js-menu-files --depth 1
unzip -d dir (creates dir/js-menu-files-master/
rsync images and menu-defs
run install_menu_defs
if [ -z "$(ls -A /library/www/html/js-menu)" ]; then
echo "Empty"
else
echo "Not Empty"
fi
if [ ! -d $MENUDIR/menu-defs.lst ]; then
# record timestamp and size of changed set of files
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/menu-defs/*.{json,html} |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/changed-menu-defs.lst
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/html/*.html |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/changed-html.lst
./bu-local $MENUDIR
fi
mkdir -p $MENUDIR/local/menu-defs
mkdir -p $MENUDIR/local/html
mkdir -p $MENUDIR/local/unedited
# copy changed files to local if this is not the first time
if [ -f $MENUDIR/menu-defs.lst ]; then
# record timestamp and size of changed set of files
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/menu-defs/*.{json,html} |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/changed-menu-defs.lst
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/html/*.html |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/changed-html.lst
./bu-local $MENUDIR
fi
rsync -av roles/js-menu/files/menu-files $MENUDIR
# restore modified files from local
cp -rf $MENUDIR/local/* $MENUDIR/menu-files
# refresh kiwix zim index - should already be done
# iiab-make-kiwix-lib
echo 'files copied'
# record timestamp and size of current set of files
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/menu-defs/*.{json,html} |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/menu-defs.lst
TZ=utc ls -l --time-style=full-iso $MENUDIR/menu-files/html/*.html |awk '{print $5" "$6":"$7" "$9}' >$MENUDIR/html.lst
# Check for user and create if absent
rc=`mysql --execute "SELECT Password FROM mysql.user where Host = 'localhost' and User = 'iiab_commenter';"`
if [ "$rc" = "" ]; then
mysql --execute "CREATE USER iiab_commenter@localhost IDENTIFIED BY 'g0adm1n';"
fi
# Create database and table
mysql < setup/comments-db.sql
echo 'database created'