Upload files to "/"

This commit is contained in:
turbine 2025-11-20 12:46:57 +01:00
parent d4a4bcc185
commit 546df7dcf0

View file

@ -6,43 +6,79 @@ URL: url à laquelle le service sera accessible (exemple.urlab.be)
IP: adresse ip locale du service (127.0.0.1 si sur cette machine, 172.23.100.X sinon) IP: adresse ip locale du service (127.0.0.1 si sur cette machine, 172.23.100.X sinon)
PORT: port utilisé par le service (entre 1 et 65535; certains ports sont déjà utilisés)" PORT: port utilisé par le service (entre 1 et 65535; certains ports sont déjà utilisés)"
error(){ error() {
echo "$USAGE" echo "$@"
exit 1 exit 1
} }
sanitize() sanitize() {
{
if ! [ "$PORT" -eq "$PORT" ] 2> /dev/null; then if ! [ "$PORT" -eq "$PORT" ] 2> /dev/null; then
error error "$USAGE"
fi fi
if 1 "<" PORT ">" 65535 ; then if [ "$PORT" -lt 1 ] || [ "$PORT" -gt 65535 ]; then
error error "$USAGE"
fi fi
case "$URL" in
*.urlab.be) SUBDOMAIN=${URL%.urlab.be} ;;
*) error "$USAGE";;
esac
if [ "$SUBDOMAIN" = "" ]; then
error "$USAGE"
fi
if [ "$(expr "$SUBDOMAIN" : '[A-Za-z0-9][A-Za-z0-9\-]\{0,61\}[A-Za-z0-9]\{0,1\}')" != "${#SUBDOMAIN}" ]; then
error "$USAGE"
fi
if [ "$IP" != "127.0.0.1" ]; then
case "$IP" in
127.0.0.1) ;;
172.23.100.[0-9]*)
LAST=${IP#172.23.100.}
if [ "$LAST" -lt 2 ] || [ "$LAST" -gt 254 ]; then
error "$USAGE"
fi ;;
*) error "$USAGE";;
esac
fi
echo "looks good"
} }
if [ $# != 3 ]; then verify() {
error if ! ping -c 1 -W 1 "$IP" >/dev/null 2>/dev/null ; then
fi error "Error : Cannot reach host $IP"
fi
if ! timeout 1 sh -c "(echo > /dev/tcp/$IP/$PORT) >/dev/null 2>&1"; then
error "Error : Port $PORT isn't open"
fi
echo "is good"
}
URL="$1" main() {
IP="$2" if [ $# != 3 ]; then
PORT="$3" error "$USAGE"
fi
sanitize URL="$1"
IP="$2"
PORT="$3"
NGINX="server {
listen 80;
listen [::]:80;
echo "$URL" server_name $URL;
echo "$IP"
echo "$PORT" location / {
# sanitize input proxy_pass http://$IP:$PORT/;
# port entre 1 et 65535 include proxy_params;
# url de la forme *.urlab.be }
# ip soit 127.0.0.1 soit 172.23.100.X, X entre 2 et 254 }"
# verifier input
# ping ip sanitize
# check si port utilisé verify
# echo "$NGINX"
# # generate config, put it in right location
# generate config, put it in right location # verify nginx config (nginx -t)
# generate ssl certificate # generate ssl certificate
}
main "$@"