1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Updated and renamed

This commit is contained in:
Zack Scholl 2016-03-19 11:31:47 -04:00
parent b1f7805ece
commit 8d4d68c840
13 changed files with 386 additions and 45 deletions

View File

@ -1,4 +1,4 @@
ADDRESS = awwkoala.com
ADDRESS = cowyo.com
PORT = 8003
CUR_DIR = $(shell bash -c 'pwd')
@ -10,40 +10,40 @@ make:
install:
rm -rf jinstall
mkdir jinstall
cp install/awwkoala.nginx jinstall/awwkoala.nginx
sed -i 's/PORT/$(PORT)/g' jinstall/awwkoala.nginx
sed -i 's/ADDRESS/$(ADDRESS)/g' jinstall/awwkoala.nginx
sed -i 's^CUR_DIR^$(CUR_DIR)^g' jinstall/awwkoala.nginx
cp install/awwkoala.init jinstall/awwkoala.init
sed -i 's/EXT_ADDRESS/$(ADDRESS)/g' jinstall/awwkoala.init
sed -i 's^CUR_DIR^$(CUR_DIR)^g' jinstall/awwkoala.init
sed -i 's^USERCUR^$(USERCUR)^g' jinstall/awwkoala.init
sed -i 's^PORT^$(PORT)^g' jinstall/awwkoala.init
cp jinstall/awwkoala.init /etc/init.d/awwkoala.init
chmod +x /etc/init.d/awwkoala.init
cp jinstall/awwkoala.nginx /etc/nginx/sites-available/awwkoala.nginx
ln -fs /etc/nginx/sites-available/awwkoala.nginx /etc/nginx/sites-enabled/awwkoala.nginx
cp install/cowyo.nginx jinstall/cowyo.nginx
sed -i 's/PORT/$(PORT)/g' jinstall/cowyo.nginx
sed -i 's/ADDRESS/$(ADDRESS)/g' jinstall/cowyo.nginx
sed -i 's^CUR_DIR^$(CUR_DIR)^g' jinstall/cowyo.nginx
cp install/cowyo.init jinstall/cowyo.init
sed -i 's/EXT_ADDRESS/$(ADDRESS)/g' jinstall/cowyo.init
sed -i 's^CUR_DIR^$(CUR_DIR)^g' jinstall/cowyo.init
sed -i 's^USERCUR^$(USERCUR)^g' jinstall/cowyo.init
sed -i 's^PORT^$(PORT)^g' jinstall/cowyo.init
cp jinstall/cowyo.init /etc/init.d/cowyo.init
chmod +x /etc/init.d/cowyo.init
cp jinstall/cowyo.nginx /etc/nginx/sites-available/cowyo.nginx
ln -fs /etc/nginx/sites-available/cowyo.nginx /etc/nginx/sites-enabled/cowyo.nginx
/etc/init.d/nginx reload
/etc/init.d/nginx restart
/etc/init.d/awwkoala.init restart
/etc/init.d/cowyo.init restart
rm -rf jinstall
binaries:
rm -rf binaries
rm -f awwkoala
rm -f cowyo
mkdir binaries
env GOOS=linux GOARCH=amd64 go build -o awwkoala -v *.go
zip -9 -r awwkoala-linux-64bit.zip awwkoala static/* templates/*
rm -f awwkoala
env GOOS=windows GOARCH=amd64 go build -o awwkoala.exe -v *.go
zip -9 -r awwkoala-windows-64bit.zip awwkoala.exe static/* templates/*
rm -f awwkoala.exe
env GOOS=linux GOARCH=arm go build -o awwkoala -v *.go
zip -9 -r awwkoala-raspberrypi.zip awwkoala static/* templates/*
rm -f awwkoala
env GOOS=darwin GOARCH=amd64 go build -o awwkoala -v *.go
zip -9 -r awwkoala-macosx-64bit.zip awwkoala static/* templates/*
rm -f awwkoala
env GOOS=linux GOARCH=amd64 go build -o cowyo -v *.go
zip -9 -r cowyo-linux-64bit.zip cowyo static/* templates/*
rm -f cowyo
env GOOS=windows GOARCH=amd64 go build -o cowyo.exe -v *.go
zip -9 -r cowyo-windows-64bit.zip cowyo.exe static/* templates/*
rm -f cowyo.exe
env GOOS=linux GOARCH=arm go build -o cowyo -v *.go
zip -9 -r cowyo-raspberrypi.zip cowyo static/* templates/*
rm -f cowyo
env GOOS=darwin GOARCH=amd64 go build -o cowyo -v *.go
zip -9 -r cowyo-macosx-64bit.zip cowyo static/* templates/*
rm -f cowyo
mv *.zip binaries/

101
install/cowyo.init Executable file
View File

@ -0,0 +1,101 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: awwkoala
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# This should be placed in /etc/init.d directory
# start with
# sudo /etc/init.d/awwkoala start
# stop with
# sudo /etc/init.d/awwkoala start
name="cowyo"
dir="CUR_DIR"
user="USERCUR"
cmd="./$name -p :PORT EXT_ADDRESS"
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0

41
install/cowyo.nginx Executable file
View File

@ -0,0 +1,41 @@
server {
# SERVER BLOCK FOR cowyo
listen 80; ## listen for ipv4; this line is default and implied
access_log /etc/nginx/logs/access-cowyo.log;
error_log /etc/nginx/logs/error-cowyo.log info;
root CUR_DIR;
server_name ADDRESS;
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ^~ /static {
try_files $uri $uri/ =404;
}
location ~ ^/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass http://127.0.0.1:PORT;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}

View File

@ -10,22 +10,22 @@ make:
install:
rm -rf jinstall
mkdir jinstall
cp awwkoala.ssl.nginx awwkoala.ssl.nginx.temp
sed -i 's/PORT/$(PORT)/g' awwkoala.ssl.nginx.temp
sed -i 's/ADDRESS/$(ADDRESS)/g' awwkoala.ssl.nginx.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' awwkoala.ssl.nginx.temp
cp awwkoala.init awwkoala.init.temp
sed -i 's/EXT_ADDRESS/$(ADDRESS)/g' awwkoala.init.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' awwkoala.init.temp
sed -i 's^USERCUR^$(USERCUR)^g' awwkoala.init.temp
sed -i 's^PORT^$(PORT)^g' awwkoala.init.temp
cp awwkoala.init.temp /etc/init.d/awwkoala.init
chmod +x /etc/init.d/awwkoala.init
cp awwkoala.ssl.nginx.temp /etc/nginx/sites-available/awwkoala.nginx
ln -fs /etc/nginx/sites-available/awwkoala.nginx /etc/nginx/sites-enabled/awwkoala.nginx
cp cowyo.ssl.nginx cowyo.ssl.nginx.temp
sed -i 's/PORT/$(PORT)/g' cowyo.ssl.nginx.temp
sed -i 's/ADDRESS/$(ADDRESS)/g' cowyo.ssl.nginx.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' cowyo.ssl.nginx.temp
cp cowyo.init cowyo.init.temp
sed -i 's/EXT_ADDRESS/$(ADDRESS)/g' cowyo.init.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' cowyo.init.temp
sed -i 's^USERCUR^$(USERCUR)^g' cowyo.init.temp
sed -i 's^PORT^$(PORT)^g' cowyo.init.temp
cp cowyo.init.temp /etc/init.d/cowyo.init
chmod +x /etc/init.d/cowyo.init
cp cowyo.ssl.nginx.temp /etc/nginx/sites-available/cowyo.nginx
ln -fs /etc/nginx/sites-available/cowyo.nginx /etc/nginx/sites-enabled/cowyo.nginx
/etc/init.d/nginx reload
/etc/init.d/nginx restart
/etc/init.d/awwkoala.init restart
/etc/init.d/cowyo.init restart
rm -rf *.temp
.PHONY: install

31
letsencrypt/Makefile~ Normal file
View File

@ -0,0 +1,31 @@
ADDRESS = yourserver.com
PORT = 8003
CUR_DIR = $(shell bash -c 'pwd')
USERCUR = $(shell bash -c 'whoami')
make:
go build
install:
rm -rf jinstall
mkdir jinstall
cp awwkoala.ssl.nginx awwkoala.ssl.nginx.temp
sed -i 's/PORT/$(PORT)/g' awwkoala.ssl.nginx.temp
sed -i 's/ADDRESS/$(ADDRESS)/g' awwkoala.ssl.nginx.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' awwkoala.ssl.nginx.temp
cp awwkoala.init awwkoala.init.temp
sed -i 's/EXT_ADDRESS/$(ADDRESS)/g' awwkoala.init.temp
sed -i 's^CUR_DIR^$(CUR_DIR)^g' awwkoala.init.temp
sed -i 's^USERCUR^$(USERCUR)^g' awwkoala.init.temp
sed -i 's^PORT^$(PORT)^g' awwkoala.init.temp
cp awwkoala.init.temp /etc/init.d/awwkoala.init
chmod +x /etc/init.d/awwkoala.init
cp awwkoala.ssl.nginx.temp /etc/nginx/sites-available/awwkoala.nginx
ln -fs /etc/nginx/sites-available/awwkoala.nginx /etc/nginx/sites-enabled/awwkoala.nginx
/etc/init.d/nginx reload
/etc/init.d/nginx restart
/etc/init.d/awwkoala.init restart
rm -rf *.temp
.PHONY: install

View File

@ -10,8 +10,8 @@ sudo ./letsencrypt-auto certonly --standalone --email youremail@somewhere.com -d
sudo service nginx start
```
Then startup `awwkoala` with
Then startup `cowyo` with
```bash
sudo ./awwkoala -p :8001 -key /etc/letsencrypt/live/yourserver.com/privkey.pem -crt /etc/letsencrypt/live/yourserver.com/cert.pem yourserver.com
sudo ./cowyo -p :8001 -key /etc/letsencrypt/live/yourserver.com/privkey.pem -crt /etc/letsencrypt/live/yourserver.com/cert.pem yourserver.com
```

17
letsencrypt/README.md~ Normal file
View File

@ -0,0 +1,17 @@
First install the NGINX block in this directory. (There is an experimental Makefile that will do this, just try `sudo make install`.
To use letsencrypt follow these steps:
```
git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
sudo service nginx stop
sudo ./letsencrypt-auto certonly --standalone --email youremail@somewhere.com -d yourserver.com
sudo service nginx start
```
Then startup `awwkoala` with
```bash
sudo ./awwkoala -p :8001 -key /etc/letsencrypt/live/yourserver.com/privkey.pem -crt /etc/letsencrypt/live/yourserver.com/cert.pem yourserver.com
```

101
letsencrypt/cowyo.init Normal file
View File

@ -0,0 +1,101 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: cowyo
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
# This should be placed in /etc/init.d directory
# start with
# sudo /etc/init.d/cowyo start
# stop with
# sudo /etc/init.d/cowyo start
dir="CUR_DIR"
user="USERCUR"
cmd="./cowyo -p :PORT -key /etc/letsencrypt/live/EXT_ADDRESS/privkey.pem -crt /etc/letsencrypt/live/EXT_ADDRESS/cert.pem yourserver.com./cowyo EXT_ADDRESS"
name="cowyo"
pid_file="/var/run/$name.pid"
stdout_log="/var/log/$name.log"
stderr_log="/var/log/$name.err"
get_pid() {
cat "$pid_file"
}
is_running() {
[ -f "$pid_file" ] && ps `get_pid` > /dev/null 2>&1
}
case "$1" in
start)
if is_running; then
echo "Already started"
else
echo "Starting $name"
cd "$dir"
sudo -u "$user" $cmd >> "$stdout_log" 2>> "$stderr_log" &
echo $! > "$pid_file"
if ! is_running; then
echo "Unable to start, see $stdout_log and $stderr_log"
exit 1
fi
fi
;;
stop)
if is_running; then
echo -n "Stopping $name.."
kill `get_pid`
for i in {1..10}
do
if ! is_running; then
break
fi
echo -n "."
sleep 1
done
echo
if is_running; then
echo "Not stopped; may still be shutting down or shutdown may have failed"
exit 1
else
echo "Stopped"
if [ -f "$pid_file" ]; then
rm "$pid_file"
fi
fi
else
echo "Not running"
fi
;;
restart)
$0 stop
if is_running; then
echo "Unable to stop, will not attempt to start"
exit 1
fi
$0 start
;;
status)
if is_running; then
echo "Running"
else
echo "Stopped"
exit 1
fi
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0

View File

@ -0,0 +1,50 @@
server {
listen 80;
server_name ADDRESS;
rewrite ^ https://$server_name$request_uri? permanent;
}
server {
# SERVER BLOCK FOR ADDRESS
listen 443 ssl;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_certificate /etc/letsencrypt/live/ADDRESS/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/ADDRESS/privkey.pem;
access_log /etc/nginx/logs/access-ADDRESS.log;
error_log /etc/nginx/logs/error-ADDRESS.log info;
root CUR_DIR;
server_name ADDRESS;
# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
expires 1M;
access_log off;
add_header Cache-Control "public";
}
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1y;
access_log off;
add_header Cache-Control "public";
}
location ^~ /static {
try_files $uri $uri/ =404;
}
location ~ ^/ {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_pass https://127.0.0.1:PORT;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
}