Browse Source

rename file; better reporting; changed variables

mxmehl 3 years ago
parent
commit
66af8fb7e6
4 changed files with 93 additions and 2 deletions
  1. 1
    0
      .gitignore
  2. 0
    1
      build-single.sh
  3. 91
    0
      fsfe-preview.sh
  4. 1
    1
      lighttpd-fsfe.conf.sample

+ 1
- 0
.gitignore View File

@@ -1 +1,2 @@
1 1
 config.cfg
2
+lighttpd-fsfe.conf

+ 0
- 1
build-single.sh View File

@@ -1 +0,0 @@
1
-/home/max/Dokumente/Selfcoded/build-single.sh

+ 91
- 0
fsfe-preview.sh View File

@@ -0,0 +1,91 @@
1
+#!/bin/bash
2
+
3
+ROOT=$(dirname "$(readlink -f "$0")")
4
+if [ ! -e "$ROOT"/config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi
5
+source "$ROOT"/config.cfg
6
+
7
+# XMLLINT test
8
+# Alles in args, selbst erkennen ob build
9
+# Webserver und Path nur anzeigen bei XHTML
10
+# CONFIG file
11
+
12
+
13
+if [ "$1" = "" ]; then
14
+  self=$(basename $0) 
15
+  echo "No parameters or variables given!"
16
+  echo
17
+  echo "Usage: "
18
+  echo
19
+  echo "$self file.en.xhtml"
20
+  echo "   -- build single XHTML file from your source to the local web directory"
21
+  echo "      the destination will be on the same relative level of the selected XHTML file"
22
+  echo "      If not a XHTML file, it will be copied to the web directory"
23
+  echo
24
+  echo "$self --copy picture.png look/style.css"
25
+  echo "   -- Just copies several files to the local web directory without even trying to build them"
26
+  exit 0
27
+fi
28
+
29
+if [ "$1" = "--copy" ]; then
30
+  numargs=$(($# - 1))
31
+  echo "[INFO] Starting a plain mass copy with $numargs files..."
32
+  for ((i=1; i <= $numargs; i++)); do
33
+    SRC_full=$(realpath $2)
34
+    DST_full=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_out|")
35
+    echo "[INFO] Copying $SRC_full to $DST_full..."
36
+    cp -R $SRC_full $DST_full
37
+    shift
38
+  done
39
+  echo "[SUCCESS] Copying finished. Files should be visible via the local webserver now."
40
+  exit 0
41
+fi
42
+
43
+SRC_rel=$1  # e.g. index.en.xhtml
44
+SRC_full=$(realpath $SRC_rel) # Full path to source file
45
+
46
+# CHECK whether the source file is located in LOC_trunk
47
+if [ ! $(echo $SRC_full | grep "$LOC_trunk") ]; then
48
+  echo "[ERROR] Given source file is not part of \$LOC_trunk (currently set to \"$LOC_trunk\"). Please only build files which reside in or below this directory. Aborting now."
49
+  exit 1
50
+fi
51
+
52
+# TEST if a DEV SVN directory is used. If yes, copy clean file to this Dir
53
+if [ "$LOC_trunk_dev" != "" ]; then
54
+  SRC_full_dev=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_trunk_dev|")
55
+  echo "[INFO] A \"dirty\" Development SVN directory ($LOC_trunk_dev) is being used. Copy file from clean SVN directory ($LOC_trunk) to Development directory..."
56
+  cp $SRC_full $SRC_full_dev  # copy file from clean SVN to dev/dirty SVN
57
+  SRC_full=$SRC_full_dev
58
+  LOC_trunk=$LOC_trunk_dev
59
+fi
60
+
61
+echo "[INFO] Using file $SRC_full as source..."
62
+
63
+### TRANSFORM XHTML file path
64
+DST_full=$(echo $SRC_full | sed -E "s|$LOC_trunk|$LOC_out|")  # replace SVN directory by build/HTTP destination
65
+
66
+### BUILD/COPY FILE depending on file extension
67
+ftype=${SRC_full##*.} # get extension of file
68
+ftype=$(echo "$ftype" | tr '[:upper:]' '[:lower:]')
69
+ftype_build="xhtml" # file types which have to be built
70
+if [[ "$ftype" == @($ftype_build) ]]; then  # file type of source has to be built
71
+  DST_full=$(echo $DST_full | sed -E "s/$ftype_build/html/")  # Replace xhtml by html
72
+  echo "[INFO] XHTML file detected. Going to build into $DST_full ..."
73
+  $LOC_trunk/build/build_main.sh process_file $SRC_full > $DST_full
74
+else  # if not built, just move it
75
+  echo "[INFO] File type ($ftype) is detected as not to be built. Just copying it to $DST_full ..."
76
+  cp $SRC_full $DST_full
77
+fi
78
+
79
+
80
+### START WEBSERVER if necessary
81
+if [ ! $(pgrep lighttpd) ]; then
82
+  echo "[INFO] Starting webserver"
83
+  /usr/sbin/lighttpd -f $HTTPDST_conf
84
+else
85
+  echo "[INFO] Webserver already seems to be running."
86
+fi
87
+
88
+### SHOW RESULTS
89
+echo
90
+DST_rel=$(echo $DST_full | sed "s|$LOC_out||") # relative path
91
+echo "[SUCCESS] Finished. File can be viewed at http://localhost:5080$DST_rel"

lighttpd-fsfe.conf → lighttpd-fsfe.conf.sample View File

@@ -5,7 +5,7 @@ $HTTP["remoteip"] !~ "127.0.0.1" {
5 5
 
6 6
 # change port and document-root accordingly
7 7
 server.port                     = 5080
8
-server.document-root            = "/home/max/subversion/fsfe/local-build/fsfe.org"
8
+server.document-root            = "/home/USER/subversion/fsfe/local-build/fsfe.org"
9 9
 server.errorlog                 = "/dev/stdout"
10 10
 server.dir-listing              = "enable"
11 11
 dir-listing.encoding            = "utf-8"

Loading…
Cancel
Save