add chrome history slurper and solana dockerfile

This commit is contained in:
Jeffrey Paul 2020-10-01 06:10:09 -07:00
parent b93b7d52f7
commit 985d7f735a
5 changed files with 201 additions and 0 deletions

24
chromeurls/urls.sh Normal file
View File

@ -0,0 +1,24 @@
#!/bin/bash
SRC="$HOME/Library/Application Support/Google/Chrome/Default/History"
Q="SELECT
datetime(last_visit_time/1000000-11644473600, \"unixepoch\") as last_visited,
last_visit_time as orig,
url,
title,
visit_count
FROM urls
ORDER BY last_visited desc
LIMIT 1
;
"
mkdir -p $HOME/tmp
cp "$SRC" $HOME/tmp/history
sqlite3 -readonly $HOME/tmp/history "$Q"
rm $HOME/tmp/history

View File

@ -0,0 +1,94 @@
FROM ubuntu:focal as builder
ENV DEBIAN_FRONTEND noninteractive
# this is the hash of solana-1.3.14
ENV VERSION c8f4bfca90e5087f77dd11921b75231c5fa30151
RUN apt update && apt install -y \
clang \
cmake \
curl \
git \
golang \
lcov \
libssl-dev \
libudev-dev \
llvm \
mscgen \
net-tools \
pkg-config \
rsync \
sudo \
zlib1g-dev \
unzip
RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
RUN . $HOME/.cargo/env && rustup component add rustfmt && rustup update
RUN git clone \
https://github.com/solana-labs/solana.git \
/usr/local/src/solana && \
cd /usr/local/src/solana && \
git checkout $VERSION
WORKDIR /usr/local/src/solana
RUN . $HOME/.cargo/env && cargo build --release
# kept crashing docker desktop, hard locks on OOM instead of doing
# something sensible. fuck closed source, proprietary software.
#RUN . $HOME/.cargo/env && cargo cargo test
#RUN . $HOME/.cargo/env rustup install nightly && cargo +nightly bench
RUN cd target/release && \
rm -f *.so *.d *.rlib && \
mv -v * /usr/local/bin
FROM ubuntu:focal as runner
COPY --from=builder /usr/local/bin/* /usr/local/bin/
ENV DEBIAN_FRONTEND noninteractive
ENV PATH $PATH:/usr/local/bin
RUN apt update && apt install -y \
runit \
runit-systemd
COPY ./supervise.sh /usr/local/sbin/supervise.sh
RUN mkdir -p /etc/service/solanad
COPY ./run.solanad /etc/service/solanad/run
RUN chmod +x /etc/service/*/run
#RUN solana transaction-count
#RUN solana-gossip spy --entrypoint devnet.solana.com:8001
RUN mkdir -p /var/lib/solana && chown nobody:nogroup /var/lib/solana
ENV HOME /var/lib/solana
WORKDIR /var/lib/solana
USER nobody:nogroup
ENV NETWORK_URL https://devnet.solana.com
#RUN solana config set --url http://devnet.solana.com
VOLUME /var/lib/solana
# rpc
EXPOSE 8899
# this daemon is stupid
EXPOSE 8000
EXPOSE 8001
EXPOSE 8002
EXPOSE 8003
EXPOSE 8004
EXPOSE 8005
EXPOSE 8005
EXPOSE 8006
EXPOSE 8007
EXPOSE 8008
EXPOSE 8009
EXPOSE 8010
USER root
WORKDIR /
CMD [ "/bin/sh", "/usr/local/sbin/supervise.sh" ]

View File

@ -0,0 +1,5 @@
docker:
docker build --progress plain -t solanad .
run:
docker run -ti solanad

View File

@ -0,0 +1,30 @@
#!/bin/bash
export HOME=/var/lib/solana
export PATH="$PATH:/usr/local/bin"
ASN="chpst -u nobody:nogroup"
cd $HOME
$ASN solana config set --url $NETWORK_URL
if [[ ! -e $HOME/validator-keypair.json ]]; then
$ASN solana-keygen new -o $HOME/validator-keypair.json
fi
$ASN solana-keygen pubkey ~/validator-keypair.json
if [[ ! -d $HOME/validator-ledger ]]; then
$ASN mkdir $HOME/validator-ledger
fi
exec $ASN \
solana-validator \
--identity $HOME/validator-keypair.json \
--trusted-validator dv1LfzJvDF7S1fBKpFgKoKXK5yoSosmkAdfbxBo1GqJ \
--no-untrusted-rpc \
--ledger $HOME/validator-ledger \
--rpc-port 8899 \
--entrypoint entrypoint.devnet.solana.com:8001 \
--expected-genesis-hash Ap36zrBt2jLWpwUjaF48hRULVgmvSE3ViFxiQgjZX2XC \
--log - \
--limit-ledger-size 2>&1

View File

@ -0,0 +1,48 @@
#!/bin/sh
shutdown() {
echo "shutting down container"
# first shutdown any service started by runit
for _srv in $(ls -1 /etc/service); do
sv force-stop $_srv
done
# shutdown runsvdir command
kill -HUP $RUNSVDIR
wait $RUNSVDIR
# give processes time to stop
sleep 0.5
# kill any other processes still running in the container
for _pid in $(ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$' | head -n -6); do
timeout -t 5 /bin/sh -c "kill $_pid && wait $_pid || kill -9 $_pid"
done
exit
}
# store enviroment variables
export > /etc/envvars
PATH=/usr/local/bin:/usr/local/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin
# run all scripts in the run_once folder
#/bin/run-parts /etc/run_once
exec runsvdir -P /etc/service &
RUNSVDIR=$!
echo "Started runsvdir, PID is $RUNSVDIR"
echo "wait for processes to start...."
sleep 5
for _srv in $(ls -1 /etc/service); do
sv status $_srv
done
# catch shutdown signals
trap shutdown SIGTERM SIGHUP SIGQUIT SIGINT
wait $RUNSVDIR
shutdown