Compare commits
4 Commits
87fc3f3f33
...
c2c501531a
Author | SHA1 | Date |
---|---|---|
BodgeMaster | c2c501531a | |
BodgeMaster | 35fdf758c0 | |
BodgeMaster | 3e567a529e | |
BodgeMaster | b7f4d35030 |
16
README.md
16
README.md
|
@ -32,21 +32,18 @@ For now, the only way to set up an instance is doing it the manual way; automati
|
|||
This setup guide is assuming that you are on a UNIX-like system and have the following already installed and set up properly:
|
||||
- Apache with PHP (will most likely also work on other web servers)
|
||||
- MySQL or MariaDB
|
||||
- Python 2 (Will be changed to Python 3 soon. If Python 2 complains about shit, it's safe to assume that someone forgot to update this.)
|
||||
- Python 3
|
||||
- Bash
|
||||
|
||||
Installation:
|
||||
|
||||
- To install the ThreadR Forum Engine, clone this repository into a directory that the web server has access to but that it outside of any web root.
|
||||
- Symlink the directory `threadr/` to your desired location on the web root.
|
||||
- Optionally symlink the file `default.html` to all places that you want to redirect to your ThreadR instance.
|
||||
- Symlink the directory `build/` to your desired location on the web root.
|
||||
- Add a database to your MySQL/MariaDB server that contains the tables shown below.
|
||||
- Create a MySQL/MariaDB user for ThreadR and grant usage privileges for the tables to it.
|
||||
- adjust the files in `config/` to your setup
|
||||
- run ./deployment-script.sh to apply configuration
|
||||
|
||||
WARNING: Currently, the configuration is permanent. It cannot be changed once the deployment script has been executed. This is a relic of our old deployment system and will change in the future.
|
||||
|
||||
Database tables:
|
||||
- boards
|
||||
- `id` (int, primary key, auto increment)
|
||||
|
@ -103,18 +100,17 @@ TBD: Remove this section when the ThreadR project moves to its final home and th
|
|||
|
||||
## Symlinks
|
||||
The following files and directories are linked to areas where they can be accessed by the web server:
|
||||
* `threadr/` → `threadr.lostcave.ddnss.de/threadr/` (all files acessible by the web server, READMEs get deleted on deployment)
|
||||
* `default.html` → `threadr.lostcave.ddnss.de/index.html` (http redirect)
|
||||
* `build/` → `threadr.lostcave.ddnss.de/` (all files acessible by the web server, READMEs get deleted on deployment)
|
||||
|
||||
# Individual documentation for each file
|
||||
### [[DIR] threadr](./threadr)
|
||||
### [[DIR] src](./src)
|
||||
This folder contains all the files that are parts of ThreadR directly
|
||||
### [[DIR] build](./build)
|
||||
Placeholder folder to link against, will be deleted and recreated by the deployment script, contains the a working instance of ThreadR after successful execution of the deployment script
|
||||
### [[DIR] config](./config)
|
||||
A place to store the configuation for a specific ThreadR instance (contains official instance config for now, will be moved elsewhere eventually)
|
||||
### [[DIR] macros](./macros)
|
||||
files for use with variable_grabbler.py
|
||||
### [default.html](./default.html)
|
||||
The main index.html on the server. It redirects to ThreadR.
|
||||
### [deployment_script.sh](./deployment_script.sh)
|
||||
This script is executed each time (or most of the time) the repository gets pushed.
|
||||
It contains the commands to execute the code variable replcement system and some other useful tasks.
|
||||
|
|
|
@ -1 +1,6 @@
|
|||
# Placeholder
|
||||
This directory is here as a placeholder for the build process.
|
||||
|
||||
# Files
|
||||
### [README.md](./README.md)
|
||||
this file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
domain_name=threadr.lostcave.ddnss.de
|
||||
threadr_dir=/threadr
|
||||
threadr_dir=/
|
||||
db_username=webstuff
|
||||
db_password=Schei// auf Pa$$w0rter!
|
||||
db_database=web
|
||||
|
|
|
@ -15,7 +15,7 @@ exit_codes = {
|
|||
"error while processing": 2
|
||||
}
|
||||
|
||||
stderr("Variable Grabbler - version 5.0_pre2\n--------------------------------------------------------------------------------")
|
||||
stderr("--------------------------------------------------------------------------------\nVariable Grabbler - version 5.0\n--------------------------------------------------------------------------------")
|
||||
################################################################################
|
||||
# Chnages in this version:
|
||||
# - complete rewrite in Python 3
|
||||
|
|
|
@ -1,97 +0,0 @@
|
|||
#!/usr/bin/python2
|
||||
|
||||
print """
|
||||
Variable Grabbler - version 4.0_pre6
|
||||
------------------------------------"""
|
||||
################################################################
|
||||
# Changes in this version:
|
||||
#===============================================================
|
||||
# *"\?" in a variable will now be replaced with a simple ?
|
||||
# before processing, remember to double escape that because
|
||||
# json doesn't like \? (=> \\?)
|
||||
# *commands are now not run over and over again if not needed
|
||||
# *files are now not rewritten for each variable individually
|
||||
# *some technical stuff
|
||||
|
||||
################################################################
|
||||
# Exit codes:
|
||||
#===============================================================
|
||||
# 0 => normal exit
|
||||
# 1 => command line argument error
|
||||
# 2 => error while processing
|
||||
#
|
||||
|
||||
# definitions
|
||||
import os, json, sys, subprocess
|
||||
|
||||
def print_err(text):
|
||||
print >> sys.stderr, text
|
||||
|
||||
if not len(sys.argv)==3:
|
||||
print_err("Error: Exactly two arguments required: \"python variable_grabbler.py <file to be rewritten> <config file>\"")
|
||||
sys.exit(1)
|
||||
|
||||
print "Reading config file...",
|
||||
config_file = open(sys.argv[2],"r")
|
||||
config_values = json.loads(config_file.read().decode("utf-8"))
|
||||
config_file.close()
|
||||
print "Done."
|
||||
|
||||
|
||||
print "Reading file: "+sys.argv[1]+"..."
|
||||
file_in = open(sys.argv[1], "r")
|
||||
file_content = file_in.read()
|
||||
file_in.close()
|
||||
|
||||
print "Replacing variables:"
|
||||
for variable in config_values:
|
||||
print "> "+variable.upper()+" => ",
|
||||
|
||||
if config_values[variable][0] == "file":
|
||||
print "Found array. Adding file instead: " + config_values[variable][1]
|
||||
file_replacement = open(config_values[variable][1], "r")
|
||||
file_content = file_content.decode('utf-8').replace("%" + variable.upper() + "%", file_replacement.read()).encode('utf-8')
|
||||
file_replacement.close()
|
||||
elif config_values[variable][0] == "exec":
|
||||
print "Found array. Executing command instead: " + config_values[variable][1]
|
||||
if variable.upper() in file_content:
|
||||
process = subprocess.Popen(config_values[variable][1], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
stdout, stderr = process.communicate()
|
||||
if process.returncode == 0:
|
||||
print "Process exited normally. Replacing variable with the output from STDOUT..."
|
||||
print_err("Subprocess exited normally.\nThe following error messages were produced:")
|
||||
print_err(stderr)
|
||||
file_content = file_content.decode('utf-8').replace("%" + variable.upper() + "%", stdout).encode('utf-8')
|
||||
else:
|
||||
print "Process exited abnormally. Exiting. No changes will be made."
|
||||
print_err("Subprocess exited abnormally. Exiting.\nThe following output was produced:")
|
||||
print_err(stdout)
|
||||
print_err("The following error messages were produced:")
|
||||
print_err(stderr)
|
||||
print "Exiting now."
|
||||
sys.exit(2)
|
||||
else:
|
||||
print variable.upper(),
|
||||
print "was not found in the file. Skipping command execution."
|
||||
else:
|
||||
replacement = str(config_values[variable])
|
||||
# look for variable sections that contain question marks
|
||||
argument_positions = []
|
||||
i = 0
|
||||
while i<len(replacement):
|
||||
if replacement[i] == '?' and (i==0 or not replacement[i-1]=='\\'):
|
||||
argument_positions = argument_positions + [ i ]
|
||||
i = i+1
|
||||
#print "DEBUG: " + str(argument_positions)
|
||||
replacement = replacement.replace("\\?", "?")
|
||||
print repr(replacement)
|
||||
# actually replace variables
|
||||
if argument_positions == []:
|
||||
file_content = file_content.decode('utf-8').replace("%" + variable.upper() + "%", replacement).encode('utf-8')
|
||||
|
||||
print "Saving new file..."
|
||||
file_out = open(sys.argv[1], "w")
|
||||
file_out.write(file_content)
|
||||
file_out.close()
|
||||
|
||||
print "Done."
|
Loading…
Reference in New Issue