Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 5 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,54 +1,9 @@
FROM node:22
FROM alpine:latest

RUN apt-get update && apt-get install -yq \
ca-certificates \
fonts-liberation \
libappindicator3-1 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libc6 \
libcairo2 \
libcups2 \
libdbus-1-3 \
libexpat1 \
libfontconfig1 \
libgbm1 \
libgcc1 \
libglib2.0-0 \
libgtk-3-0 \
libnspr4 \
libnss3 \
libpango-1.0-0 \
libpangocairo-1.0-0 \
libstdc++6 \
libx11-6 \
libx11-xcb1 \
libxcb1 \
libxcomposite1 \
libxcursor1 \
libxdamage1 \
libxext6 \
libxfixes3 \
libxi6 \
libxrandr2 \
libxrender1 \
libxss1 \
libxtst6 \
lsb-release \
vim \
wget \
xdg-utils \
&& apt-get clean

RUN echo 'kernel.unprivileged_userns_clone=1' > /etc/sysctl.d/userns.conf
RUN apk add --no-cache bash curl

WORKDIR /app
COPY get-nextcloud-cookie.sh .
RUN chmod +x get-nextcloud-cookie.sh

ADD . /app

RUN npm install

ENV NODE_TLS_REJECT_UNAUTHORIZED=0

CMD ["sh", "-c", "runuser --user www-data -- node index.js"]
ENTRYPOINT ["/app/get-nextcloud-cookie.sh"]
9 changes: 9 additions & 0 deletions get-nextcloud-cookie.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
export REQUESTTOKEN=`curl --dump-header header.txt --silent --insecure -X GET "$SERVER_ROOT/login"|grep "requesttoken"|sed -n 's/.*data-requesttoken="\([^"]*\)".*/\1/p' | sed -e 's/[+]/%2B/g'`
export NEXT_COOKIE=`cat header.txt | grep Set-Cookie | sort -u |sed -e 's/Set-Cookie: //'|sed -e 's/; .*/; /i' | tr -d '\r\n'`
export INIT_COOKIE=`cat header.txt | grep Set-Cookie | grep -E "(Host-nc|oc_session)" | sort -u |sed -e 's/Set-Cookie: //'| sed -e 's/; .*/; /i' | tr -d '\r\n'`
export OLD_SESSION=`cat header.txt | grep Set-Cookie | grep -v -E "(Host-nc|oc_session)" | sort -u |sed -e 's/Set-Cookie: //'| sed -e 's/; .*/; /i' | tr -d '\r\n'`
export PAYLOAD="user=$USERNAME&password=$PASSWORD&rememberme=1&timezone=Europe/Amsterdam&timezone_offset=2&requesttoken=$REQUESTTOKEN"
export COOKIE=`curl --cookie "$NEXT_COOKIE" --silent --insecure --dump-header - -X POST "$SERVER_ROOT/login" -H "Content-Type: application/x-www-form-urlencoded" -H "Origin: $SERVER_ROOT" --data "$PAYLOAD" |grep "Set-Cookie" |grep -v "$OLD_SESSION" |sort -u |sed -e 's/Set-Cookie: //'|sed -e 's/; .*/; /i' |tr -d '\r\n'`
export COOKIE="$INIT_COOKIE$COOKIE"
echo $COOKIE
34 changes: 0 additions & 34 deletions index.js

This file was deleted.

Loading
Loading