refactor: v3
This commit is contained in:
parent
f05a04bf19
commit
0d8090e3c8
26 changed files with 55 additions and 242 deletions
|
@ -1,7 +0,0 @@
|
|||
FROM python:3.10-alpine
|
||||
|
||||
RUN apk add git
|
||||
RUN git clone https://git.faulty.nl/didier/dotfiles /app
|
||||
|
||||
WORKDIR /app
|
||||
ENTRYPOINT ["python3", "/app/lib/docker.py"]
|
|
@ -1,18 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
REPO_LIST="https://git.faulty.nl/didier/dotfiles"
|
||||
DOTFILES_DIR="$HOME/.local/dotfiles"
|
||||
|
||||
clone() {
|
||||
for repo in $REPO_LIST; do
|
||||
git clone "$repo" "$DOTFILES_DIR" && return 0
|
||||
done
|
||||
}
|
||||
|
||||
main() {
|
||||
[ -d "$DOTFILES_DIR" ] || clone
|
||||
cd "$DOTFILES_DIR" || exit 1
|
||||
./comp.sh "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
|
@ -1,31 +0,0 @@
|
|||
# any HTTP request returns the contents of: ./lib/deploy.sh
|
||||
# If the deploy script is older then a day, do a git pull
|
||||
|
||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||
import subprocess
|
||||
import os
|
||||
import time
|
||||
|
||||
class handler(BaseHTTPRequestHandler):
|
||||
def do_GET(self):
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type','text/plain')
|
||||
self.end_headers()
|
||||
if (time.time() - os.path.getmtime('./lib/deploy.sh') > 86400) or self.path == '/pull':
|
||||
subprocess.call(['git', 'pull'])
|
||||
with open('./lib/deploy.sh') as f:
|
||||
self.wfile.write(bytes(f.read(), 'utf-8'))
|
||||
self.wfile.write(bytes("# Git pull: " + str(time.time() - os.path.getmtime('./lib/deploy.sh')) + " seconds ago", 'utf-8'))
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
server = HTTPServer(('', 80), handler)
|
||||
print('started httpserver...')
|
||||
server.serve_forever()
|
||||
except KeyboardInterrupt:
|
||||
print('^C received, shutting down the web server')
|
||||
server.socket.close()
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
32
lib/lib.sh
32
lib/lib.sh
|
@ -1,32 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ./sync.conf || . ../sync.conf
|
||||
|
||||
DRY_RUN=${DRY_RUN:-no}
|
||||
|
||||
bool() {
|
||||
case "$1" in
|
||||
1|true|yes|on|TRUE|YES|ON) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
run() {
|
||||
# Check if command starts with NO_RUN ($*) and remove it
|
||||
if echo "$*" | grep -q "^NO_RUN"; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if bool "$DRY_RUN"; then
|
||||
echo "DRY: + $*"
|
||||
else
|
||||
echo "+ $*"
|
||||
"$@"
|
||||
fi
|
||||
}
|
||||
|
||||
is_graphical() {
|
||||
command -v $PREF_TERM > /dev/null && return 0 || return 1
|
||||
}
|
||||
|
||||
command -v $SYS_SUDO > /dev/null || SYS_SUDO="NO_RUN"
|
Loading…
Add table
Add a link
Reference in a new issue