Big merge with fred and ipfs install improvements

This commit is contained in:
poka 2020-03-27 02:01:26 +01:00
commit ea13bacfc6
53 changed files with 3856 additions and 230 deletions

75
.install/copylaradio.sh Executable file
View File

@ -0,0 +1,75 @@
#!/bin/bash
copylaradio() {
###########################################
echo "NO READY TO USE. REWRITING..." && exit 1
###########################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
isARM=$(cat $MY_PATH/.OS | grep YES)
##################################
## INSTALL TOOLS
######## YOUTUBE-DL ##########
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl || err=1
sudo chmod a+rx /usr/local/bin/youtube-dl
sudo apt install libid3-tools mpd mpc lame omxplayer -y || err=1
## CONFIG MPD
sudo cp -f $MY_PATH/mpd.conf /etc/mpd.conf
sudo sed -i "s/_USER/$USER/g" /etc/mpd.conf || err=1
sudo chown -R $USER /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
sudo service mpd restart || err=1
sudo apt-get install nginx php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y || err=1
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y #libav-tools || err=1
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc libid3-tools espeak mpg321 fuse atomicparsley -y || err=1
wget http://launchpadlibrarian.net/339874908/libav-tools_3.3.4-2_all.deb -O $MY_PATH/libav-tools.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-data_1.0+git20130326-3_all.deb -O $MY_PATH/libttspico-data.deb
if [[ $isARM ]]; then
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico0.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-3_armhf.deb -O $MY_PATH/libttspico-utils.deb
else
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico0_1.0+git20130326-5_amd64.deb -O $MY_PATH/libttspico0.deb
wget http://ftp.fr.debian.org/debian/pool/non-free/s/svox/libttspico-utils_1.0+git20130326-9_amd64.deb -O $MY_PATH/libttspico-utils.deb
fi
sudo dpkg -i $MY_PATH/libttspico-data.deb || err=1
sudo dpkg -i $MY_PATH/libttspico0.deb || err=1
sudo dpkg -i $MY_PATH/libttspico-utils.deb || err=1
sudo dpkg -i $MY_PATH/libav-tools.deb || sudo apt --fix-broken install -y || err=1
rm $MY_PATH/libttspico-data.deb $MY_PATH/libttspico0.deb $MY_PATH/libttspico-utils.deb $MY_PATH/libav-tools.deb
# CONFIG NGINX
sudo cp -f $MY_PATH/default /etc/nginx/sites-available/
sudo sed -i "s/_USER/$USER/g" /etc/nginx/sites-available/default
sudo systemctl restart nginx || err=1
#################################
## Get _CopyLaRadio distrib
# ipfs get Qm.... > /tmp/copylaradio.zip
# Add CopyLaRadio to system PATH
#export PATH=$PATH:/home/$USER/_CopyLaRadio
# etc....
# INSTALL ROMPR WebSite LINKs
sudo ln -s $MY_PATH/../www/rompr /var/www/rompr
sudo chmod 777 $MY_PATH/../www/rompr/albumart
sudo chmod 777 $MY_PATH/../www/rompr/prefs
if [[ $err ]]; then
echo -e "${c_red}Installation de copylaradio incomplète$c_"
exit 1
else
echo -e "${c_green}CopyLaRadio a été installé avec succès$c_"
exit 0
fi
}
$@

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -0,0 +1,31 @@
#!/usr/bin/env bash
# Enable camera on Raspberry Pi
# set_config_var taken from raspi-config
set_config_var() {
lua - "$1" "$2" "$3" <<EOF > "$3.bak"
local key=assert(arg[1])
local value=assert(arg[2])
local fn=assert(arg[3])
local file=assert(io.open(fn))
local made_change=false
for line in file:lines() do
if line:match("^#?%s*"..key.."=.*$") then
line=key.."="..value
made_change=true
end
print(line)
end
if not made_change then
print(key.."="..value)
end
EOF
sudo mv "$3.bak" "$3"
}
# Command extracted from raspi-config
sed /boot/config.txt -i -e "s/^startx/#startx/"
sed /boot/config.txt -i -e "s/^fixup_file/#fixup_file/"
set_config_var start_x 1 /boot/config.txt
set_config_var gpu_mem 128 /boot/config.txt

52
.install/ipfs-pi-stream/install Executable file
View File

@ -0,0 +1,52 @@
#!/usr/bin/env bash
set -e
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# Enable camera on the Raspberry Pi
sudo "$BASE_DIR/enable-camera.sh"
# Install ffmpeg and supporting tools
sudo apt-get install -y ffmpeg lsof inotify-tools nginx
# Copy placeholder for audio-only streams
cp "$BASE_DIR/audio.jpg" "$HOME/audio.jpg"
# Add user to be able to modify nginx directories
sudo usermod -a -G "$USER" www-data
sudo chmod g+rw /var/www/html
# TODO: why is this needed?
sudo chmod a+rw /var/www/html
sudo cp -f "$BASE_DIR/process-stream.sh" /usr/bin/process-stream.sh
sudo cp -f "$BASE_DIR/process-stream.service" /etc/systemd/system/process-stream.service
sudo systemctl daemon-reload
sudo systemctl enable process-stream
# Add hourly job to clear out old data
echo "41 * * * * $USER /usr/local/bin/ipfs repo gc" | sudo tee --append /etc/crontab
# Install the ipfs video player
mkdir "$BASE_DIR/tmp"
current_dir="$(pwd)"
git clone https://github.com/tomeshnet/ipfs-live-streaming.git "$BASE_DIR/tmp/ipfs-live-streaming"
cd "$BASE_DIR/tmp/ipfs-live-streaming"
git checkout b9be352582317e5336ddd7183ecf49042dafb33e
cd "$current_dir"
VIDEO_PLAYER_PATH="$BASE_DIR/tmp/ipfs-live-streaming/terraform/shared/video-player"
sed -i s#__IPFS_GATEWAY_SELF__#/ipfs/# "$VIDEO_PLAYER_PATH/js/common.js"
sed -i s#__IPFS_GATEWAY_ORIGIN__#https://ipfs.io/ipfs/# "$VIDEO_PLAYER_PATH/js/common.js"
IPFS_ID=$(ipfs id | grep ID | head -n 1 | awk -F\" '{print $4}')
sed -i "s#live.m3u8#/ipns/$IPFS_ID#" "$VIDEO_PLAYER_PATH/js/common.js"
sed -i s#__M3U8_HTTP_URLS__#\ # "$VIDEO_PLAYER_PATH/js/common.js"
cp -r "$VIDEO_PLAYER_PATH" /var/www/html/video-player
rm -rf "$BASE_DIR/tmp"
# Add entry into nginx home screen
APP="<div class='app'><h2>IPFS Pi Stream Player</h2>IPFS Video player for Pi Stream. <br />M3U8 Stream located <a href='/ipns/$IPFS_ID'>over ipns</a> <br/><a href='/video-player/'>Go </a> and play with built in video player</div>"
sudo sed -i "s#<\!--APPLIST-->#$APP\n<\!--APPLIST-->#" "/var/www/html/index.html"

View File

@ -0,0 +1,16 @@
[Unit]
Description=Service to process RTMP stream
Wants=network.target
After=ipfs.service
[Service]
Type=simple
User=pi
Group=pi
ExecStart=/usr/bin/process-stream.sh
ExecStop=/bin/kill -s QUIT $MAINPID
Restart=on-failure
RestartSec=10s
[Install]
WantedBy=multi-user.target

View File

@ -0,0 +1,124 @@
#!/usr/bin/env bash
HLS_TIME=40
M3U8_SIZE=3
IPFS_GATEWAY="https://ipfs.io"
# Load settings
# Prepare Pi Camera
sudo modprobe bcm2835-v4l2
sudo v4l2-ctl --set-ctrl video_bitrate=100000
function startFFmpeg() {
while true; do
mv ~/ffmpeg.log ~/ffmpeg.1
echo 1 > ~/stream-reset
# Stream Raspberry Pi Camera
ffmpeg -f video4linux2 -input_format h264 -video_size 1280x720 -framerate 30 -i /dev/video0 -vcodec copy -hls_time "${HLS_TIME}" "${what}.m3u8" > ~/ffmpeg.log 2>&1
# Stream FM Station from a SDR module (see contrib/pi-stream to install drivers)
# Frequency ends in M IE 99.9M
# rtl_fm -f 99.9M -M fm -s 170k -A std -l0 -E deemp -r 44.1k | ffmpeg -r 15 -loop 1 -i ../audio.jpg -f s16le -ac 1 -i pipe:0 -c:v libx264 -tune stillimage -preset ultrafast -hls_time "${HLS_TIME}" "${what}.m3u8" > ~/ffmpeg 2>&1
sleep 0.5
done
}
# Create directory for HLS content
currentpath="$HOME/live"
sudo umount "${currentpath}"
rm -rf "${currentpath}"
mkdir "${currentpath}"
sudo mount -t tmpfs tmpfs "${currentpath}"
# shellcheck disable=SC2164
cd "${currentpath}"
what="$(date +%Y%m%d%H%M)-LIVE"
# Start ffmpeg in background
startFFmpeg &
while true; do
#TODO# Fix this one
# shellcheck disable=SC2086,SC2012
nextfile=$(ls -tr ${what}*.ts 2>/dev/null | head -n 1)
if [ -n "${nextfile}" ]; then
# Check if the next file on the list is still being written to by ffmpeg
if lsof "${nextfile}" | grep -1 ffmpeg; then
# Wait for file to finish writing
# If not finished in 45 seconds something is wrong, timeout
inotifywait -e close_write "${nextfile}" -t ${HLS_TIME}
fi
# Grab the timecode from the m3u8 file so we can add it to the log
timecode=$(grep -B1 "${nextfile}" "${what}.m3u8" | head -n1 | awk -F : '{print $2}' | tr -d ,)
attempts=5
until [[ "${timecode}" || ${attempts} -eq 0 ]]; do
# Wait and retry
sleep 0.5
timecode=$(grep -B1 "${nextfile}" "${what}.m3u8" | head -n1 | awk -F : '{print $2}' | tr -d ,)
attempts=$((attempts-1))
done
if ! [[ "${timecode}" ]]; then
# Set approximate timecode
timecode="${HLS_TIME}.000000"
fi
reset_stream=$(cat ~/stream-reset)
reset_stream_marker=''
if [[ ${reset_stream} -eq '1' ]]; then
reset_stream_marker=" #EXT-X-DISCONTINUITY"
fi
echo 0 > ~/stream-reset
# Current UTC date for the log
time=$(date "+%F-%H-%M-%S")
# Add ts file to IPFS
ret=$(ipfs add --pin=false "${nextfile}" 2>/dev/null > ~/tmp.txt; echo $?)
attempts=5
until [[ ${ret} -eq 0 || ${attempts} -eq 0 ]]; do
# Wait and retry
sleep 0.5
ret=$(ipfs add --pin=false "${nextfile}" 2>/dev/null > ~/tmp.txt; echo $?)
attempts=$((attempts-1))
done
if [[ ${ret} -eq 0 ]]; then
# Update the log with the future name (hash already there)
echo "$(cat ~/tmp.txt) ${time}.ts ${timecode}${reset_stream_marker}" >> ~/process-stream.log
# Remove nextfile and tmp.txt
rm -f "${nextfile}" ~/tmp.txt
# Write the m3u8 file with the new IPFS hashes from the log
totalLines="$(wc -l ~/process-stream.log | awk '{print $1}')"
sequence=0
if ((totalLines>M3U8_SIZE)); then
sequence=$((totalLines-M3U8_SIZE))
fi
{
echo "#EXTM3U"
echo "#EXT-X-VERSION:3"
echo "#EXT-X-TARGETDURATION:${HLS_TIME}"
echo "#EXT-X-MEDIA-SEQUENCE:${sequence}"
} > current.m3u8
tail -n ${M3U8_SIZE} ~/process-stream.log | awk '{print $6"#EXTINF:"$5",\n'${IPFS_GATEWAY}'/ipfs/"$2}' | sed 's/#EXT-X-DISCONTINUITY#/#EXT-X-DISCONTINUITY\n#/g' >> current.m3u8
# Add m3u8 file to IPFS and IPNS publish
m3u8hash=$(ipfs add current.m3u8 | awk '{print $2}')
ipfs name publish --timeout=5s "${m3u8hash}" &
# Copy files to web server
cp current.m3u8 /var/www/html/live.m3u8
cp ~/process-stream.log /var/www/html/live.log
fi
else
sleep 5
fi
done

View File

@ -0,0 +1,18 @@
#!/usr/bin/env bash
set -e
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
sudo systemctl stop process-stream
sudo systemctl disable process-stream
sudo rm -f /usr/bin/process-stream.sh
sudo rm -f /etc/systemd/system/process-stream.service
sudo systemctl daemon-reload
# Remove ffmpeg and supporting tools
sudo apt-get -y remove ffmpeg lsof inotify-tools
# Revert permissions
sudo chmod 755 /var/www/html
sed -i "/ipfs repo gc/d" | sudo tee --append /etc/crontab

View File

@ -36,6 +36,12 @@ ipfs_install() {
echo "INSTALL latest ipfs"
sudo ipfs-update install latest || err+="Install IPFS"
fi
if [[ ! -f /etc/systemd/system/ipfs.service ]]; then
echo "CREATE SYSTEMD ipfs SERVICE"
sudo cp -f $BASE_DIR/ipfs.service /etc/systemd/system/
sudo sed -i "s/_USER/$USER/g" /etc/systemd/system/ipfs.service
echo "CREATE SYSTEMD ipfs SERVICE"
[[ -f /etc/systemd/system/ipfs.service ]] && sudo rm /etc/systemd/system/ipfs.service
@ -62,6 +68,8 @@ ipfs_install() {
######### UPDATE BOOTSTRAP LIST ###########
ipfs bootstrap rm --all
sudo systemctl daemon-reload || err+="Restart IPFS"
}
ipfs_install

View File

@ -1,7 +1,161 @@
#!/bin/bash
# https://pad.p2p.legal/scuttlebot?both#Social-Layer-ScuttleBut-server
scuttlebutt() {
echo "TODO"
echo -e "${c_yellow}Onboarding SCUTTLEBUTT...$c_"
where_is_ssb_installed=$(which ssb-server)
mkdir -p ~/.zen
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [[ ! $where_is_ssb_installed ]]; then
# Install dependencies
sudo apt-get install -y socat python3-dev libtool python3-setuptools autoconf automake
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
source ~/.bashrc
nvm install --lts
# Install ssb-server and config in ~/.ssb_astroport
[[ ! -d ~/.ssb_astroport ]] && mkdir -p ~/.ssb_astroport
cd ~/.ssb_astroport
### Install module in ~/.ssb_astroport/node_modules
npm install sodium-native ssb-backlinks ssb-ws ssb-links ssb-query ssb-secret-blob ssb-private
npm install -g ssb-server
### Install oasis webclient (could replace ssb-server, TODO: try it)
# npm -g install fraction/oasis#semver:
# Move node_modules with ssb-server (why do I have to do that? crazy heavy crappy wonderful node.js )
ssbSERVER=$(which ssb-server)
node_bin_path=$(dirname $ssbSERVER)
node_lib_path=$(dirname $ssbSERVER | sed s/bin/lib/)
mv ~/.ssb_astroport/node_modules/* $node_lib_path/node_modules/
# Create sblob symlink
ln -s $node_lib_path/node_modules/ssb-secret-blob/index.js $node_bin_path/sblob
# INSTALL sbotc
if [[ ! $(which sbotc) ]]; then
sudo apt install libsodium-dev jq -y
git clone https://git.scuttlebot.io/%25133ulDgs%2FoC1DXjoK04vDFy6DgVBB%2FZok15YJmuhD5Q%3D.sha256 sbotc
cd sbotc
make
sudo make install
fi
fi
# TEST ssb-server Install
ssbSERVER=$(which ssb-server)
[[ $ssbSERVER == "" ]] && echo "Check your ssb-server install... Cannot find it !!" && exit 1
# If exists backup ~/.ssb to ~/.ssb_$USER SSB (one time only !)
[[ -d ~/.ssb_$USER ]] && echo "BACKUP already existing... ~/.ssb_$USER !!! Manual check please..." && exit 1
[[ -d ~/.ssb ]] && [[ ! -d ~/.ssb_$USER ]] && mv ~/.ssb ~/.ssb_$USER
# CREATE ~/.ssb_astroport
[[ ! -d ~/.ssb_astroport ]] && mkdir -p ~/.ssb_astroport && cd ~/.ssb_astroport
# if exists, keep ~/.ssb_$USER/secret*
[[ ! -f ~/.ssb_astroport/secret ]] && [[ -f ~/.ssb_$USER/secret ]] && cp -f ~/.ssb_$USER/secret* ~/.ssb_astroport/
# Symlink ~/.ssb -> ~/.ssb_astroport
[[ -L ~/.ssb ]] && rm ~/.ssb
[[ -d ~/.ssb_astroport ]] && ln -s ~/.ssb_astroport ~/.ssb
# Create config (TODO: adapt if public Pub or Local Node)
# TODO: Create unique hostname in swarm !! uidna
nodename=$(cat /etc/hostname)
extension=$(echo $nodename | cut -d '.' -f 2)
if [[ $extension == $nodename ]]; then
nodename=$nodename.local
# LOCAL
cat > ~/.ssb/config <<EOF
{
"connections": {
"incoming": {
"net": [
{ "scope": "public", "host": "0.0.0.0", "external": ["$nodename"], "transform": "shs", "port": 8008 }
]
},
"outgoing": {
"net": [{ "transform": "shs" }]
}
}
}
EOF
cat > ~/.zen/run-ssb_$nodename.sh <<EOF
#!/bin/bash
echo _$ > ~/.zen/ssb.pid.bash
while true; do
ssb-server start
echo _! > ~/.zen/ssb.pid
done
EOF
# REPLACE _ with $
sed -i s/_/\$/g ~/.zen/run-ssb_$nodename.sh
chmod 755 ~/.zen/run-ssb_$nodename.sh
ssb-server start &
else
# PUB
cat > ~/.ssb/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public", "external": ["$nodename"], "transform": "shs", "port": 8008
},
{ "scope": "private", "host": "127.0.0.1", "transform": "shs", "port": 8008 }
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF
cat > ~/.zen/run-ssb_$nodename.sh <<EOF
#!/bin/bash
echo _$ > ~/.zen/ssb.pid.bash
while true; do
ssb-server start --host $nodename
echo _! > ~/.zen/ssb.pid
done
EOF
# REPLACE _ with $
sed -i s/_/\$/g ~/.zen/run-ssb_$nodename.sh
chmod 755 ~/.zen/run-ssb_$nodename.sh
ssb-server start --host $nodename &
fi
echo "
_ __ __ _
_ _ .__|_o _ (_ (_ |_)
(_(_)| || |(_| __)__)|_)
_|
$nodename
"
echo '
__ _ _ _ _
(_ |_|_)\ /|_|_) o._ o_|_
__)|_| \ \/ |_| \ || || |_ ... SCUTTLEBUTT ... OK?
'
echo "DOES SCUTTELBUTT IS RUNNING FINE?"
echo "Then add $HOME/.zen/run-ssb_$nodename.sh & TO YOUR '/etc/rc.local' !!! "
}
$@

66
.install/silkaj-php-mysql.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash
###########################################
echo "NO READY TO USE. REWRITING..." && exit 1
###########################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
OS=$(head -n1 $MY_PATH/.OS)
isARM=$(cat $MY_PATH/.OS | grep YES)
unset err
# Basics
sudo apt update
echo -e "${c_yellow}Mise à jours des prérequis...$c_"
sudo apt install curl jq zip unzip htop tree ntpdate gnupg mpack imagemagick qrencode build-essential base58 bc -y
# Silkaj + Duniterpy
silkaj() {
echo -e "${c_yellow}Installation de Silkaj...$c_"
libsodium=$(sudo apt-cache search libsodium 2>/dev/null | grep -v -E "header|debug symbols" | grep "Network communication" -B1 | head -n1 | awk -F '-' '{ print $1 }')
[[ $libsodium =~ " " ]] && libsodium=$(echo $libsodium | awk '{ print $2 }')
sudo apt install libsodium-dev libssl-dev libffi-dev python3-pip python3-wheel $libsodium -y || err+="Install python3 and $libsodium"
pip3 install duniterpy || err+="Install duniterpy"
pip3 install silkaj --user || err+="Install Silkaj"
source .profile ## PATH="$HOME/.local/bin:$PATH"
}
# Install PHP + MySQL (TODO: REWRITE!!)
php() {
echo -e "${c_yellow}Installation de PHP et MySQL$c_"
if [[ $OS == "buster" ]]; then
sudo apt -y install software-properties-common nginx php php-common php-fpm php-gettext php-gd php-mysql php-curl php-imap php-mbstring php-xml php-cli mariadb-server || err+="Install PHP and MySQL"
elif [[ $OS == "stretch" ]]; then
sudo apt -y install lsb-release apt-transport-https ca-certificates || err+="Install apt-transport-https"
sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg || err+="Download PHP key"
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php7.3.list
sudo apt update
sudo apt -y install software-properties-common dirmngr nginx php7.3 php7.3-common php7.3-gettext php7.3-fpm php7.3-gd php7.3-mysql php7.3-curl php7.3-imap php7.3-mbstring php7.3-xml php7.3-cli mariadb-server || err+="Install PHP and MySQL"
else
echo "${c_red}Votre système n'est pas pris en charge par ce script d'installation.$c_"
exit 1
fi
isLocalhostUsers=$(sudo mysql -e "select user from mysql.user;" | grep "localhost")
isTestDB=$(sudo mysql -e "show databases" | grep "test")
[[ -n $isLocalhostUsers ]] && sudo mysql -e "DROP USER ''@'localhost'; DROP USER ''@'$(hostname)'"
[[ -n $isTestDB ]] && sudo mysql -e "DROP DATABASE test"
sudo mysql -e "FLUSH PRIVILEGES"
}
# Read arguments
for i in $@; do
echo -e "${c_yellow}Installation de $c_light$i$c_"
$i
done
if [[ $err ]]; then
echo -e "${c_red}Installation des prérequis incomplète: $err$c_"
exit 1
else
echo -e "${c_green}Les prérequis ont été correctement installés$c_"
exit 0
fi

View File

@ -0,0 +1,7 @@
{
"plugins": {
"ssb-private": true,
"ssb-backlinks": true,
"patchfoo": true
}
}

65
.install/ssb-patchfoo/install Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/env bash
# shellcheck disable=SC1091
true
VERSION="TO-V0.5"
BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
CURRENT_DIR="$(pwd)"
# Install node.js shared module
# shellcheck source=../shared/node.js/install
source "$BASE_DIR/../shared/node.js/install"
# Make folder if service did not
mkdir -p ~/.ssb/node_modules || true
# shellcheck disable=SC2164
cd ~/.ssb/node_modules
# Install dependencies
npm install --unsafe-perm asyncmemo hashlru pull-stream pull-cat multicb hyperscript pull-paramap ssb-contact ssb-sort stream-to-pull-stream emoji-server pull-paginate ssb-mentions busboy mime-types pull-identify-filetype human-time pull-hyperscript jpeg-autorotate pull-catch diff pull-split pull-utf8-decoder ssb-web-resolver highlight.js pull-box-stream base64-url ssb-backlinks ssb-private
# Install patchfoo and enable plugin
git clone https://github.com/tomeshnet/patchfoo.git patchfoo
(
# shellcheck disable=SC2164
cd patchfoo
git checkout ${VERSION}
)
# Replace ssb-server plugins.install with a static config file
# This will prevent the installation of these modules a second time
# and compiling downlevel for a 3rd time
cp "$BASE_DIR/config" ~/.ssb
#ssb-server plugins.install ssb-private
#ssb-server plugins.install ssb-backlinks
#ssb-server plugins.enable patchfoo
# Stop ssb service to process plugin
sudo systemctl stop ssb
# Disable the git-ssb and npm-ssb prerequisite
# Comment out two lines in patchwork that create a prerequisite for git-ssb and npm-ssb
# but don't seem to serve any purpose. git-ssb and and npm-ssbis not available on npm
sed -i 's#var Git#//var Git#' patchfoo/lib/app.js patchfoo/lib/app.js
sed -i 's#this.git = new Git(this.sbot, this.config)#//this.git = new Git(this.sbot, this.config)#' patchfoo/lib/app.js
sed -i 's#var SsbNpmRegistry#//var SsbNpmRegistry#' patchfoo/lib/app.js patchfoo/lib/app.js
sed -i 's#this.serveSsbNpmRegistry = SsbNpmRegistry.respond(this.sbot, this.config)#//this.serveSsbNpmRegistry = SsbNpmRegistry.respond(this.sbot, this.config)#' patchfoo/lib/app.js
# Comment out line that breaks things
sed -i "s#h('input', {type: 'file', name: 'upload'})#//h('input', {type: 'file', name: 'upload'})#" patchfoo/lib/serve.js
# Start service again to start patchfoo
sudo systemctl start ssb
# Install nginx reverse proxy file
sudo cp "$BASE_DIR/ssb-patchfoo.conf" /etc/nginx/site-path-enabled/ssb-patchfoo.conf
# Add entry into nginx home screen
APP="<div class='app'><h2>Patch Foo</h2>Plain SSB web UI. <br/><a href='/patchfoo'>Go</a></div>"
sudo sed -i "s#<\!--APPLIST-->#$APP\n<\!--APPLIST-->#" "/var/www/html/index.html"
# shellcheck disable=SC2164
cd "$CURRENT_DIR"

View File

@ -0,0 +1,9 @@
location /patchfoo {
proxy_pass http://127.0.0.1:8027/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
sub_filter "=\"/" "=\"/patchfoo/";
sub_filter_once off;
}

74
.install/ssl.sh Executable file
View File

@ -0,0 +1,74 @@
#!/bin/bash
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
### Vars
args=$(echo $@ | tr " " "\n")
if [[ "$args" =~ "DOMAIN=" ]]; then
DOMAIN=$(echo "$args" | grep "\<DOMAIN=" | awk -F '=' '{ print $2 }')
else
echo "Veuillez sélectionner un domaine avec DOMAIN=mondommain.com"
exit 1
fi
if [[ "$args" =~ "APP=" ]]; then
APP=$(echo "$args" | grep "\<APP=" | awk -F '=' '{ print $2 }')
else
echo "Veuillez sélectionner une application avec APP=monapp"
exit 1
fi
action=$(echo "$args" | grep -v "=")
[[ ! $action =~ ^(on|off|certif)$ ]] && echo "Veuillez choisir on, off ou certif pour créer un certificat ssl" && exit 1
###
install_certbot(){
sudo apt update
if [[ $(grep -E 'stretch|buster' /etc/os-release) ]]; then
sudo apt install certbot python-certbot-nginx -y
elif [[ $(grep -E '16.|17.|18.|19.' /etc/os-release) ]]; then
sudo apt install software-properties-common
sudo add-apt-repository universe
sudo add-apt-repository ppa:certbot/certbot
sudo apt update
sudo apt install certbot python-certbot-nginx
else
echo "OS non supporté pour certbot." && exit 1
fi
}
create_certificate() {
sudo certbot --nginx certonly --non-interactive --agree-tos -m $USER@$DOMAIN -d $DOMAIN && echo "Le certificat de $DOMAIN a bien été déployé" || echo "Une erreur s'est produite lors de la création du certificat SSL"
## Cronification
[[ ! -e /opt/scripts ]] && sudo mkdir /opt/scripts
sudo cp $MY_PATH/templates/rproxy/ssl_renew.sh /opt/scripts/
[[ -z $(sudo crontab -l | grep "/opt/scripts/ssl_renew.sh") ]] && (sudo crontab -l ; sudo echo "12 2 * * 1 /opt/scripts/ssl_renew.sh") | sudo crontab -u root -
}
case $action in
on)
sudo sed -i 's/ #if/ if/g' /etc/nginx/conf.d/$APP.conf
sudo sed -i 's/ #add/ add/g' /etc/nginx/conf.d/$APP.conf
sudo sed -i "s/listen 443;/listen 443 ssl;/g" /etc/nginx/conf.d/$APP.conf
[[ ! -d /etc/nginx/includes ]] && sudo mkdir /etc/nginx/includes
sudo cp $MY_PATH/templates/rproxy/ssl.conf /etc/nginx/includes/
sudo sed -i "/Content-Security-Policy/a \ include includes/ssl.conf;\n ssl_certificate /etc/letsencrypt/live/$DOMAIN/fullchain.pem;\n ssl_certificate_key /etc/letsencrypt/live/$DOMAIN/privkey.pem;" /etc/nginx/conf.d/$APP.conf
;;
off)
sudo sed -i "s/ if/ #if/g" /etc/nginx/conf.d/$APP.conf
sudo sed -i "s/ add/ #add/g" /etc/nginx/conf.d/$APP.conf
sudo sed -i "/ssl.conf;/d" /etc/nginx/conf.d/$APP.conf
sudo sed -i "/ssl_certificate/d" /etc/nginx/conf.d/$APP.conf
;;
certif)
[[ ! $(which certbot) ]] && install_certbot
if sudo test ! -f /etc/letsencrypt/live/$DOMAIN/fullchain.pem; then create_certificate; fi
;;
esac

View File

@ -0,0 +1,27 @@
music_directory "/home/_USER/music"
playlist_directory "/home/_USER/playlists"
user "$USER"
bind_to_address "any"
auto_update "yes"
zeroconf_enabled "yes"
zeroconf_name "CopyLaRadio Music Recorder"
filesystem_charset "UTF-8"
id3v1_encoding "UTF-8"
###############################
audio_output {
type "pulse"
name "My Pulse Output"
server "127.0.0.1"
}
audio_output {
type "httpd"
name "CopyLaRadio HTTP Stream"
encoder "lame"
port "8000"
quality "5.0"
# bitrate "128"
format "44100:16:1"
}

View File

@ -4,7 +4,7 @@ After=network.target
[Service]
User=_USER
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --enable-gc
ExecStart=/usr/local/bin/ipfs daemon --enable-pubsub-experiment --enable-namesys-pubsub --routing=dhtclient --enable-gc
Restart=on-failure
[Install]

View File

@ -3,19 +3,19 @@ title: 'EVASION NUMERIQUE'
---
# ASTROPORT
## is Not an Astroport
## [is Not an Astroport](./ANA)
===
### **FR: Internet est cassé**
**EN: The Internet is broken |
DE: Das Internet ist kaputt |
ES: La Internet está rota |
PT: A Internet está quebrada |
IT: Internet è rotto |
NL: Het internet is kapot |
PL: Internet jest zepsuty |
RU: Интернет сломан**
### **FR: [Internet est cassé](./ANA/01.home/default.fr.md)**
**EN: [The Internet is broken](./ANA/01.home/default.en.md) |
DE: [Das Internet ist kaputt](./ANA/01.home/default.de.md) |
ES: [La Internet está rota](./ANA/01.home/default.es.md) |
PT: [A Internet está quebrada](./ANA/01.home/default.pt.md) |
IT: [Internet è rotto](./ANA/01.home/default.it.md) |
NL: [Het internet is kapot](./ANA/01.home/default.nl.md) |
PL: [Internet jest zepsuty](./ANA/01.home/default.pl.md) |
RU: [Интернет сломан](./ANA/01.home/default.ru.md)**
===

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

BIN
doc/images/astrban.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

BIN
doc/images/astroport1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 KiB

BIN
doc/images/astroport2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 KiB

BIN
doc/images/astroport3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
doc/images/astroport4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 KiB

BIN
doc/images/astroport5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 120 KiB

BIN
doc/images/astroport6.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

BIN
doc/images/astroport7.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

2602
doc/images/astroport7.svg Normal file

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 123 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 248 KiB

BIN
doc/images/colors.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 634 KiB

BIN
doc/images/money_wizard.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
doc/images/sucram.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 MiB

BIN
doc/message_fred.mp3 Normal file

Binary file not shown.

Binary file not shown.

View File

@ -47,7 +47,7 @@ sed -i 's/_GPATH/$MY_PATH/g' $MY_PATH/.profile
chmod u+x $MY_PATH/.install/*.sh
$MY_PATH/.install/export_colors.sh
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases
[[ -f ~/.bash_aliases ]] && source ~/.bash_aliases # POKA ?
# --------------------------------------------

View File

@ -34,5 +34,11 @@ server {
proxy_set_header X-Forwarded-For $remote_addr;
}
location /ipns {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}

View File

@ -0,0 +1,71 @@
<!Doctype HTML>
<head>
<title>Patchwork Invite</title>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/source-code-pro" type="text/css"/>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/fantasque-sans-mono" type="text/css"/>
<link rel="stylesheet" href="stylesheet.css" title="Stylesheet" type="text/css" media="screen" charset="utf-8">
</head>
<body>
<div class="container">
<img src="https://solarpunk.cool/images/invite-letterhead.jpg" class="logo">
<div>
<h2>Hi, {recipient}!</h2>
<h2> Come talk to me on Scuttlebutt! It's a decentralized social network with a radically different experience from Facebook or Twitter. It's unique, supportive, cool, and reminds me of what the web must have felt like at the very beginning.</h2>
<h2>Because it's so radically different (like, it's not actually <em>on the web</em>) it takes a few steps to get started, which i've helpfully included below!</h2>
<h2 class="steps-title">How to Join Scuttlebutt, and How to Find Me on The Network:</h2>
<ol>
<li class="steps">Download Patchwork, a client for navigating Scuttlebutt.</li>
<p>Scuttlebutt is a <em>method</em> for decentralized communication, but there are different clients to choose from for navigating this scuttleverse(sort of like choosing between chrome and firefox for the web). Patchwork is my preferred client, and you can download it below:</p>
<div class="link-box">
<div class="link-button"><a href="http://dinosaur.is/patchwork-downloader/" target="_blank" >Download Patchwork</a></div>
<p class="caption">(opens in new window)</p>
</div>
<li class="steps">Install and start up The Patchwork application.</li>
<img class="gif" src="https://solarpunk.cool/images/installing-patchwork.gif">
<li class="steps">Paste in a pub invite code.</li>
<p>Pubs are like happy, always-on robot friends that are great at relaying messages for us. The pub helps us talk to one another when we're not on the same local network.</p>
<p><em>You can find me on this pub: <span class="accent-text">{pub}</span></em></p>
<p><<em>And you can join by clicking 'join pub' and pasting in this invite code:</em></p>
<p><strong class="invite-code accent-text">{invite-code}</strong></p>
<img class="gif" src="https://solarpunk.cool/images/pub-invite.gif">
<li class="steps">Hang out for a sec as you are synced up with the network.</li>
<img class="gif" src="https://solarpunk.cool/images/download.gif" style="max-width: 800px; margin-top: 30px;">
<p>With Scuttlebutt, you own and hold your own data, which is your social network. But this means that when you first join the pub, all the messages in your network are downloaded to your computer. This keeps the entire network decentralized and not reliant on any server (unlike facebook or twitter). It also means you can browse the entire network while being offline!</p>
<p>Since it's made up of mostly text, the network will take up about 500mb on yr computer, and the downloading should take less than 5 minutes.</p>
<p>While you wait, check out this video that better explains how Scuttlebutt works, through the context of a <span class="accent-text">*~*~</span>love story<span class="accent-text">*~*~</span>:</p>
<div class="link-box">
<div class="link-button"><a href="https://vimeo.com/236358264" target="_blank">Scuttlebutt: a Love Story</a></div>
<p class="caption">(opens in new window)</p>
</div>
<li class="steps">Find Me and Friend Me.</li>
<p>My name on here is <span class="accent-text">{username}.</span></p>
<p>But you should find me using my public key, which is:</p>
<p class="invite-code accent-text">{public-key}</p>
<p>The public key is sort of like my techno-signature, so you know that the person you are friending is actually me.</p>
<p>You can find me by pasting my public key into the search bar. This'll bring you to my profile, where you can follow me.</p>
<img class="gif" src="https://solarpunk.cool/images/search-for-me.gif">
<li class="steps">Say Hi!</li>
<p>You can write either public or private messages. The private ones are end-to-end encrypted, meaning it's impossible for anyone who isn't me to read them.</p>
</br>
<p class="caption">To send me a private message, click private, then add my @name and say hi!</p>
<img class="gif closer" src="https://solarpunk.cool/images/writing-private-message.gif">
<p class="caption">To send a public message, either just post in the public thread (and maybe @mention me) or post in the #new-people channel (which is what I'd recommend)</p>
<img class="gif closer" src="https://solarpunk.cool/images/writing-public-message.gif">
<li class="steps">Check out these other channels.</li>
<p>There's a lot of good conversations happening on this network. Here are three channels I think you'd like. Just paste them into patchwork's search bar to check them out!</p>
<ul class="accent-text" style="line-height: 1.6em;">
<li>{channel-one}</li>
<li>{channel-two}</li>
<li>{channel-three}</li>
</ul>
</ol>
<div class="closing-remarks">
<p> I'm excited to talk to you through Scuttlebutt! Let me know if you have any problems starting up!</p>
<h2><em> - {sender}</em></h2>
</div>
</div>
</div>
</body>

View File

@ -0,0 +1,92 @@
body{
font-family: 'SourceCodeProRegular';
font-weight: normal;
font-style: normal;
font-size: 16px;
margin: 20px; }
.title{
margin: auto;
font-size: 3em; }
h2{
font-size: 1.35em;
color; #202329;
font-weight: lighter; }
.container{
max-width: 960px;
margin: auto; }
.logo{
max-width: 100%;
display: block;
margin: auto; }
a{
color: inherit;
text-decoration: none; }
.letterhead-title{
margin-top: auto;
margin-bottom: auto; }
.steps-title{
font-weight: bold;
margin-top: 60px;
margin-bottom: 40px;
font-style: normal;
color: #015249; }
.steps{
color: #48a47d;
font-size: 1.1em;
font-weight: bold;
margin-top: 60px;
margin-bottom: 10px; }
.link-box{
max-width: 300px;
text-align: center;
margin: auto; }
.link-button{
background-color: #015249;
color: white;
padding: 10px; }
.caption{
font-size: 0.8em;
margin-top: 1px;
margin-bottom: 1px;
font-style: italic; }
.accent-text{
color: #77c9d4;
font-weight: bold;
font-style: normal; }
.invite-code{
font-family: 'FantasqueSansMonoRegular';
font-style: normal;
font-weight: lighter;
font-size: 1.1em;
line-height: 1.3em; }
.gif{
max-width: 600px;
display: block;
margin: auto;
margin-top: 40px;
margin-bottom: 40px;
-webkit-filter: drop-shadow(2px 2px 2px #a5a5af);
filter: drop-shadow(2px 2px 2px #a5a5af); }
.closer{
margin-top: 10px;
}
.closing-remarks{
margin-top: 60px;
margin-bottom: 60px; }

View File

@ -42,11 +42,3 @@ find /tmp -ctime +1 -type f -name "cmd_SPAM_*" -exec rm -f '{}' \; 2>/dev/null
return 0
}
########################################################################
# PUBLISH ~/.zen/ipfs ON /ipns/$NODEIPNS
function ipfs_node_publish (){
IWALLETS=$(ipfs add -rHq '~/.zen/ipfs' | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
echo $IWALLETS
}

View File

@ -14,7 +14,7 @@ echo "
############# $ME DELAY
########################################################################
# ex: ./$ME \"10 days\"
# SCAN NODE G1 Wallet FOR ZEN Command received (or pending) TX/IN
# Survey Node G1 Wallet for TX/IN Commands in received comments ...
########################################################################
_(_)_ _(_)_
@ -30,13 +30,9 @@ echo "
"
DELAY="$1"
# GET DUNITER SERVER
DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh)
DUNITERURL="https://$DUNITERNODE"
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ $IPFSNODEID == "" ]] && echo "$USER Please Install IPFS !!" && exit 1
[[ ! -d ~/.zen/scan ]] && mkdir -p ~/.zen/scan # Directory containing G1 blockchain incoming TX Scan
[[ ! -d ~/.zen/cache/g1_TX_inputs ]] && mkdir -p ~/.zen/cache/g1_TX_inputs # Directory containing G1 blockchain incoming TX Scan
[[ ! -d ~/.zen/ipfs ]] && mkdir -p ~/.zen/ipfs # Directory where NODE store SMS & other Channel Wallets
[[ ! -d ~/.zen/ipfs_swarm ]] && mkdir -p ~/.zen/ipfs_swarm # Local copy of all SSB friends IPFS Nodes published ipfs
@ -65,90 +61,126 @@ fi
#########################################################################################################
echo "======================================="
echo "IPFS ID = $IPFSNODEID"
echo "IPFS Node ID = $IPFSNODEID
__
_|_ _ _| |\ | _ _| _ /__/| _.|| __|_
(_| |(/_(_|< | \|(_)(_|(/_ \_| | \/\/(_|||(/_|_
last $DELAY
G1 PUBKEY = $NODE_G1PUBKEY
SSB ID = %$ssbpub.ed25519
echo "G1 PUBKEY = $NODE_G1PUBKEY"
echo "SSB ID = %$ssbpub.ed25519"
echo "
#############################################
# GET G1 WALLET AMOUNT
silkaj -p $DUNITERNODE balance $NODE_G1PUBKEY
#############################################"
echo "Checking G1 Wallet received TX ($DELAY) for ZEN command"
"
# PREPARE TIMESTAMP LIMITS
TIMEBEFORE=$(date -u --date="-$DELAY" +"%s")
TIMESTAMP=$(date -u +"%s")
# GET DUNITER SERVER
DUNITERNODE=$($MY_PATH/tools/duniter_getnode.sh)
DUNITERURL="https://$DUNITERNODE"
# GET BLOCKCHAIN TX FOR TIME WINDOW
curl -s $DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP > ~/.zen/g1zen.scan
## TODO VERIFY ~/.zen/g1zen.scan IS GOOD ?! AND RETRY... $DUNITERURL
curl -s $DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP > /tmp/g1_TX.scan.txt
TXNB=$(cat /tmp/g1_TX.scan.txt | wc -l)
###########################################################################
# TX EXTRACTION
###########################################################################
# MORE THAN MINUTE DELAY = history.received
echo "
$DUNITERURL/tx/history/$NODE_G1PUBKEY/times/$TIMEBEFORE/$TIMESTAMP
___
|\/ ._ ._ _ |_ _ ._
G1 |/\ | ||_|| | ||_)(/_|
$TXNB
"
# Choose between "history.received" OR "history.pending" depending on DELAY
if [[ $DELAYUNIT != "minutes" && $DELAYUNIT != "minute" ]]; then
# HOW MANY TX DO WE HAVE...
TXnb=$(cat ~/.zen/g1zen.scan | jq '.history.received[].hash' | wc -l)
TXnb=$(cat /tmp/g1_TX.scan.txt | jq '.history.received[].hash' | wc -l)
echo "DETECTED $TXnb TX... Checking TX/IN..."
# PARSE $TXnb TX
line=1
while [[ $line -le $TXnb ]]; do
# GET TX HASH
TXhash=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].hash' | head -n $line | tail -n 1 )
TXhash=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].hash' | head -n $line | tail -n 1 )
# IT IS A NEW TX?
if [[ ! -f ~/.zen/scan/zen.$TXhash ]]; then
if [[ ! -f ~/.zen/cache/g1_TX_inputs/zen.$TXhash ]]; then
# GET LAST TX ISSUER
ISSUER=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].issuers[0]' | head -n $line | tail -n 1)
ISSUER=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].issuers[0]' | head -n $line | tail -n 1)
[[ $ISSUER == $NODE_G1PUBKEY ]] && ((line++)) && continue ## TX/OUT CONTINUE
echo $ISSUER > ~/.zen/scan/zen.$TXhash
echo $ISSUER > ~/.zen/cache/g1_TX_inputs/zen.$TXhash
# GET OUTPUTS AND MAKE ZEN=G1*100 SUM
ZEN=$(cat ~/.zen/g1zen.scan | jq -r '.history.received[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
ZEN=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.received[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
# GET COMMENT
COMMENT=$(cat ~/.zen/g1zen.scan | jq '.history.received' | jq -r '.[].comment' | head -n $line | tail -n 1)
COMMENT=$(cat /tmp/g1_TX.scan.txt | jq '.history.received' | jq -r '.[].comment' | head -n $line | tail -n 1)
# echo "TX-IN $ISSUER => $NODE_G1PUBKEY"
echo "TX/IN :: $ZEN ZEN from $ISSUER :: $COMMENT ($TXhash)"
echo "Received $ZEN Zen From $ISSUER :: $COMMENT :: ($TXhash)"
CMD=$(echo "$COMMENT" | awk '{print toupper($1)}')
echo "
___ ___ _ ___ _
|\/ | |\ ||_)| || |_) _ _ _ o _ _|
|/\ _|_| \|| |_|| | \(/_(_(/_|\/(/_(_|
"
# Add CASE for received here
###### CREATE ZEN VALUE IN IPFS #########
[[ $CMD == "ZEN" ]] && $MY_PATH/zen_MAKE.sh $ZEN $TXhash $ISSUER
############################################
# else
# STILL OLD TX
# [[ $TXhash != "" ]] && echo "ALREADY TREATED TX/IN: $TXhash $(cat ~/.zen/scan/zen.$TXhash)" || echo "NO TX"
fi
((line++))
done
else
# MINUTE DELAY = pending // TODO: if anyone succeed in passing $VAR in jq command, both can be merge...
# MINUTE DELAY = pending // TODO: if anyone succeed in passing $VAR in jq command, both can be merge...
# HOW MANY TX DO WE HAVE...
TXnb=$(cat ~/.zen/g1zen.scan | jq '.history.pending[].hash' | wc -l)
TXnb=$(cat /tmp/g1_TX.scan.txt | jq '.history.pending[].hash' | wc -l)
echo "DETECTED $TXnb TX... Checking TX/IN..."
# PARSE $TXnb TX
line=1
while [[ $line -le $TXnb ]]; do
TXhash=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].hash' | head -n $line | tail -n 1)
TXhash=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].hash' | head -n $line | tail -n 1)
# IT IS A NEW TX/IN?
if [[ ! -f ~/.zen/scan/zen.$TXhash ]]; then
if [[ ! -f ~/.zen/cache/g1_TX_inputs/zen.$TXhash ]]; then
# GET LAST RX ISSUER
ISSUER=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].issuers[0]' | head -n $line | tail -n 1)
ISSUER=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].issuers[0]' | head -n $line | tail -n 1)
[[ $ISSUER == $NODE_G1PUBKEY ]] && ((line++)) && continue ## TX/OUT CONTINUE
echo $ISSUER > ~/.zen/scan/zen.$TXhash
echo $ISSUER > ~/.zen/cache/g1_TX_inputs/zen.$TXhash
# GET OUTPUTS AND MAKE ZEN SUM
ZEN=$(cat ~/.zen/g1zen.scan | jq -r '.history.pending[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
ZEN=$(cat /tmp/g1_TX.scan.txt | jq -r '.history.pending[].outputs[]' | grep $NODE_G1PUBKEY | head -n $line | tail -n 1 | cut -d ':' -f 1)
# GET COMMENT
COMMENT=$(cat ~/.zen/g1zen.scan | jq '.history.pending' | jq -r '.[].comment' | head -n $line | tail -n 1)
COMMENT=$(cat /tmp/g1_TX.scan.txt | jq '.history.pending' | jq -r '.[].comment' | head -n $line | tail -n 1)
# echo "TX-IN $ISSUER => $NODE_G1PUBKEY"
echo "TX/IN :: $ZEN ZEN from $ISSUER :: $COMMENT ($TXhash)"
echo "Pending $ZEN Zen From $ISSUER :: $COMMENT :: ($TXhash)"
CMD=$(echo "$COMMENT" | awk '{print toupper($1)}')
echo "
___ ___ _ ___ _
|\/ | |\ ||_)| || |_)_ ._ _|o._ _
|/\ _|_| \|| |_|| | (/_| |(_||| |(_|
_|
"
# Add CASE for pending here
###### CREATE ZEN VALUE IN IPFS #########
[[ $CMD == "ZEN" ]] && $MY_PATH/zen_MAKE.sh $ZEN $TXhash $ISSUER
############################################
# else
# STILL OLD TX
# [[ $TXhash != "" ]] && echo "ALREADY TREATED TX/IN: $TXhash $(cat ~/.zen/scan/zen.$TXhash)" || echo "NO TX"
fi
((line++))
done
fi
echo "FINISH"
echo "FINISH !
__
|\ | _ _| _ /__/| \ /_.|| __|_ |_ _.| _.._ _ _
| \|(_)(_|(/_ \_| | \/\/(_|||(/_|_ |_)(_||(_|| |(_(/_
silkaj -p $DUNITERNODE balance $NODE_G1PUBKEY
"
exit 0

View File

@ -1,23 +0,0 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.22
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$ME'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# [ASTROPORT](https://astroport.com)
########################################################################'
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
IPFSNODEID=$(ipfs id -f='<id>\n')
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)

View File

@ -14,7 +14,7 @@ echo '
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# Initialize G1SSB account + IPFS Publish
# Initialize SSB + G1SSB about + IPFS Node publish
########################################################################
o__ __o __o o__ __o o__ __o o__ __o
/v v\ __|> /v v\ /v v\ <| v\
@ -30,138 +30,88 @@ echo '
# [ASTROPORT](https://astroport.com)
########################################################################
'
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
IPFSNODEID=$(ipfs id -f='<id>\n')
# CREATE ~/.zen/ipfs/.$IPFSNODEID/G1SSB
##############################################
[[ $IPFSNODEID == "" ]] && echo "ERROR missing IPFSNODEID" && exit 1
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/G1SSB
EXTERNAL=$(cat /etc/hostname).local
[[ "$1" == "KILL" ]] && rm -f ~/.ssb/config && kill -9 $(cat ~/.zen/ssb.pid.bash) && killall node && echo "
_ _ _ _
| | (_) | |
| | ___| | |
| |/ / | | |
| <| | | |
|_|\_\_|_|_|
"
########################################################################
# ENVIRONEMENT DETECTION + IPFS ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_info
########################################################################
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ $ipfsnodeid == "" ]] && echo "ERROR missing IPFS Node id !! IPFS is not installed !?" && exit 1
########################################################################
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
if [[ $ssbpub == "" ]]; then
[[ "$1" == "RESET" ]] && rm -Rf ~/.ssb.$USER
[[ -d ~/.ssb.$USER ]] && echo "Backup already exists $USER. RESET autoremove... MANUAL : rm -Rf ~/.ssb.$USER " && exit 1
[[ -d ~/.ssb ]] && mv ~/.ssb ~/.ssb.$USER && rm -Rf ~/.ssb # BACKUP ~/.ssb
mkdir -p ~/.ssb
echo "
_ __ __ _
_ _ .__|_o _ (_ (_ |_)
(_(_)| || |(_| __)__)|_)
_|
$EXTERNAL
"
[[ -f ~/.ssb/config ]] && cp -f ~/.ssb/config ~/.ssb/config.bkp
cat > ~/.ssb/config <<EOF
{
"connections": {
"incoming": {
"net": [
{
"scope": "public", "external": ["$EXTERNAL"], "transform": "shs", "port": 8008
},
{ "scope": "private", "transform": "shs", "port": 8008, "host": "127.0.0.1" }
]
},
"outgoing": {
"net": [
{
"transform": "shs"
}
]
}
}
}
EOF
echo '
__ _ _ _ _
(_ |_|_)\ /|_|_) o._ o_|_
__)|_| \ \/ |_| \ || || |_
'
cat > ~/.zen/run-ssb-PUB_$EXTERNAL.sh <<EOF
#!/bin/bash
echo _$ > ~/.zen/ssb.pid.bash
while true; do
ssb-server start --host $EXTERNAL 2>/tmp/ssb.debug
echo _! > ~/.zen/ssb.pid
done
EOF
[[ $1 == "PROD" ]] && sed -i s/tmp/dev/g ~/.zen/run-ssb-PUB_$EXTERNAL.sh && sed -i sed -i s/ssb\.debug/null/g ~/.zen/run-ssb-PUB_$EXTERNAL.sh # PROD=/dev/null
sed -i s/_/\$/g ~/.zen/run-ssb-PUB_$EXTERNAL.sh
chmod 755 ~/.zen/run-ssb-PUB_$EXTERNAL.sh
~/.zen/run-ssb-PUB_$EXTERNAL.sh &
sleep 5
[[ -f ~/.ssb/secret.dunikey ]] && cp ~/.ssb/secret.dunikey ~/.ssb/secret.dunikey.$(date -u +%s%N | cut -b1-13)
ssbpub=$(sbotc whoami 2>/dev/null | jq -r .id)
fi
# secret.dunikey ? NODE_G1PUBKEY
[[ $ssbpub == "" ]] && echo "ERROR ssb-server NOT running !! Please check it..." && exit 1
########################################################################
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
########################################################################
echo "
$ssbpub
_____ _____ _
(_ | /\ |_)||_| \
oooooooo__) |/--\| \||_|_/ !!!!!!!!!!!!!!
"
# IPFS LOCAL REPOSITORY for Node Identity G1 + SSB
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/G1SSB
## PUBLISH ABOUT MESSAGE
##############################################
# CREATE G1 wallet QRCode
qrcodefile=~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.qrcode.png
qrencode -s 5 -o $qrcodefile "$NODE_G1PUBKEY"
# IMAGE of G1 wallet QRCode
qrcodefile=~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png
qrencode -s 5 -o $qrcodefile "$g1pub"
# Publish G1 Wallet PUBKEY QRCode to SSB
# Prepare QRCode File for SSB
name=${qrcodefile##*/}
id="$(sbotc blobs.add < $qrcodefile)"
type="$(file -b --mime-type $qrcodefile)"
size="$(wc -c < $qrcodefile)"
# Publish ABOUT
sbot publish --type about --about $ssbpub --description "Welcome to [Astroport](https://astroport.com) G1SSB/IPFS Station [$IPFSNODEID](http://localhost:8080/ipns/$IPFSNODEID)" --name "$USER@$(cat /etc/hostname)" --image "$id"
# Publish QRCode FILE post
sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to order ZenTag...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
# COPY NODE G1SSB ID to IPFS
echo "$ssbpub" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_ssb.whoami
echo "$NODE_G1PUBKEY" > ~/.zen/ipfs/.$IPFSNODEID/G1SSB/_g1.pubkey
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
echo "
/\ |_ _ _|_
/--\|_)(_)|_||_ message published
/--\|_)(_)|_||_ : PUBLISH to SSB feed...
$ssbpub
$ssbpub
http://localhost:8080/ipns/$IPFSNODEID/.$IPFSNODEID/G1SSB/
-- sbot publish --
"
sbot publish --type about --about $ssbpub --description "[Astroport](https://astroport.com) Station [$ipfsnodeid](http://localhost:8080/ipns/$ipfsnodeid) - G1 Wallet $g1pub" --name "$USER@$(cat /etc/hostname)" --image "$id"
INVITATION : $(sbotc invite.create 1)
echo "
_ _
/ \|_) _ _ _| _
\_X| \ (_(_)(_|(/_
$g1pub
~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.qrcode.png
-- sbotc publish --
"
sbotc publish '{"type":"post","text":"[G1SSB_Wallet.png]('"$id"')\nUse https://cesium.app to send payment.\nComment your transaction with '"'Zen'"' to order ZenTag...","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
echo "
___ _ _ __
| |_)|_(_ _. _| _|
_|_| | __) (_|(_|(_|
~/.zen/ipfs
"
# COPY NODE G1SSB ID to IPFS
echo "$ssbpub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_ssb.whoami
echo "$g1pub" > ~/.zen/ipfs/.$ipfsnodeid/G1SSB/_g1.pubkey
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --allow-offline --quieter /ipfs/$IWALLETS)
echo "
ipfs ls /ipns/$NODEIPNS
_ _ _ _ _
(_)_ ____ _(_) |_ __ _| |_(_) ___ _ __
| | _ \ \ / / | __/ _| | __| |/ _ \| _ \
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_|
# This INVITE is to be sent an 'Astroport Station' willing to Join our IPFS Swarm.
# see 'ssb_SURVEY_contact.sh' for commands executed...
"
INVITE=$(sbotc invite.create 1)
echo $INVITE
# This INVITE is to be sent an "Astroport Station" willing to Join our IPFS Swarm.
# sbot_SURVEY.sh is taking care of checking SSB Feed for commands...

134
zen/ssb_SURVEY_contact.sh Executable file
View File

@ -0,0 +1,134 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# SURVEY SSB contact from "invite" is happening in feed
######################################################################## _ _ _ _ _
(_)_ ____ _(_) |_ __ _| |_(_) ___ _ __
| | _ \ \ / / | __/ _| | __| |/ _ \| _ \
| | | | \ V /| | || (_| | |_| | (_) | | | |
|_|_| |_|\_/ |_|\__\__|_|\__|_|\___/|_| |_| contact SURVEY
# New Station is joining ASTROPORT !!
DETECT in SSB feed messages "type": "contact", "autofollow": true
LIKE
https://tube.p2p.legal/videos/watch/ef319fdd-caf1-4e03-ba22-91c456e94f73
{
"key": "%jVQewn0/ey0tfdvYCjYXJqVivaaZ6NpeUL9xK5QeGTk=.sha256",
"value": {
"previous": "%ilrZ+8CvMXpu09LWh75Uq37j7lVJnoxTvipyooRSjpg=.sha256",
"sequence": 3,
"author": "@S2KB1zRQNAuCRs1vW08c+63+0gjI2egDj4pjUUrt+dw=.ed25519",
"timestamp": 1585068288462,
"hash": "sha256",
"content": {
"type": "contact",
"following": true,
"autofollow": true,
"contact": "@t/giTDc0EtzdPQGC7iAAzgzVOkFo++XZRvzOOlqgX1c=.ed25519"
},
"signature": "kXsFqfBGqZXZApf7UANDYlqnwLXuGdWFbMMofljBOp4dNGc4dAv+P2hzK3XV/jPT8a1u7PHIraJASugR1NCLCw==.sig.ed25519"
},
"timestamp": 1585068290213
}
'
# CACHE
[[ ! -d ~/.zen/cache/ssb_contact ]] && mkdir -p ~/.zen/cache/ssb_contact
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
messages=$(sbotc query.read '{"query":[{"$filter":{"value":{"content":{"type":"contact", "contact":"'"$self"'", "autofollow":true}}}}]}')
while read -r msg
do
timestamp=$(printf %s "$msg" | jq .value.timestamp)
echo '
_ _ ___ ____
/ / \|\ || /\ / |
\_\_/| \||/--\\_ | RECEIVED'
echo $timestamp
author=$(printf %s "$msg" | jq -r .value.author)
[[ "$author" == "$self" ]] && echo "Message from myself" && continue
g1author=$(printf %s "$msg" | jq -r .value.author | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
# Crypt, ipfs store, send
if [[ -f ~/.ipfs/swarm.key ]]; then
ipfsnodeid=$(ipfs id -f='<id>\n')
mkdir -p ~/.zen/ipfs/.${ipfsnodeid}/CONTACT/${g1author}
# PUBLISH swarm.key.crypt to IPFS, so PUB can push new swam.key to our CONTACT
file=~/.zen/ipfs/.${ipfsnodeid}/CONTACT/${g1author}/ipfs_swarm.key.crypt
$MY_PATH/tools/natools.py encrypt -p ${g1author} -i ~/.ipfs/swarm.key -o ${file}
# IPFS Node PUBLISH Adresses so Pub can become bootstrap for ${g1author}
ipfs id | jq -r .Addresses[] > ~/.zen/ipfs/.${ipfsnodeid}/Addresses
# IPFS Node PUBLISH AgentVersion & repo.stat
ipfs id | jq -r .AgentVersion > ~/.zen/ipfs/.${ipfsnodeid}/AgentVersion
ipfs repo stat > ~/.zen/ipfs/.${ipfsnodeid}/repo.stat
boostrap=$(cat ~/.zen/ipfs/.${ipfsnodeid}/Addresses | tail -n 1)
echo "
$author
\|/ \|/ \|/
/|\ /|\ /|\ cyphering swarmkey
~/.zen/ipfs/.${ipfsnodeid}/CONTACT/${g1author}/ipfs_swarm.key.crypt
PUBLISH IPFS
http://localhost:8080/ipns/
"
ipfs name publish --quieter /ipfs/$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
name=${file##*/}
id="$(sbotc blobs.add < "$file")"
type="$(file -b --mime-type "$file")"
size="$(wc -c < "$file")"
echo '
______ _ _ _ ____ __ _ _ _ _ _____
/\ (_ ||_)/ \|_)/ \|_)|__(_\ //\ |_)|\/||/|_\_/ |_)/ \(_ |
/--\__) || \\_/| \_/| \| __)\/\//--\| \| ||\|_ | | \_/__) |
'
echo "SSB
#astroport-swarmkey
[$name]($id)
TO.SSB_${author}
TO.G1_${g1author}
+++
FROM.SSB_${self_name}
FROM.G1_${g1self}
FROM.IPFS_${ipfsnodeid}
"
sbotc publish '{"type":"post","text":"#astroport-swarmkey = ['"$name"']('"$id"') TO.SSB_'"$author"' TO.G1_'"$g1author"' +++ FROM.SSB_'"$self_name"' FROM.G1_'"$g1self"' FROM.IPFS_'"$ipfsnodeid"'","mentions":[{"link":"'"$id"'","name":"'"$name"'","size":'"$size"',"type":"'"$type"'"}]}'
else
echo "NO swarm.key here."
fi
done < <(printf '%s\n' "$messages")

39
zen/ssb_SURVEY_swarmkey.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
########################################################################
# Author: Fred (support@qo-op.com)
# Version: 2020.03.24
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
########################################################################
MY_PATH="`dirname \"$0\"`" # relative
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
ME="${0##*/}"
echo '
########################################################################
# \\///
# qo-op
############# '$MY_PATH/$ME'
########################################################################
# ex: ./'$ME'
# SURVEY received #astroport-swarmkey and copy it to IPFS
######################################################################## _ _ _ _ _
___ _ _ __
| |_)|_(_ _ _.._._ _ | _
_|_| | __) _>\/\/(_|| | | ||<(/_\/
/
USED ONLY ONCE... Next swarm.key change will use ipfs.
'
self=$(sbotc whoami | jq -r .id) || exit 1
g1self=$(echo $self | cut -d '@' -f 2 | cut -d '.' -f 1 | base64 -d | base58)
self_name=$(sbotc query.read '{"query":[{"$filter":{"value":{"author": "'"$self"'", "content":{"type":"about", "about": "'"$self"'"}}}}]}' | jq -r .value?.content?.name | grep -v null | tail -n 1)
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ ! $ipfsnodeid ]] && echo "ERROR ipfs id" && exit 1
messages=$(sbotc backlinks.read '{"query":[{"$filter":{"dest":"#astroport-swarmkey","value":{"content":{"type":"post"}}}}]}')
while read -r msg
do
done < <(printf '%s\n' "$messages")

View File

@ -51,6 +51,7 @@ checkonenode()
}
# Temp dir where results are stored
rm -Rf /tmp/zen/gnodewatch
DIR=/tmp/zen/gnodewatch
export DIR
mkdir -p $DIR/chains

View File

@ -28,11 +28,11 @@ PARK="$5" # Zen amount payed for IPFS PIN by passenger everyday
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
IPFSNODEID=$(ipfs id -f='<id>\n')
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
echo "G1SSB Wallet: $NODE_G1PUBKEY
IPFS: $IPFSNODEID
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
echo "G1SSB Wallet: $g1pub
IPFS: $ipfsnodeid
__ __ _ _ _______
_______ _ __ | \/ | / \ | |/ / ____|
|_ / _ \ '_ \ | |\/| | / _ \ | ' /| _|
@ -122,16 +122,16 @@ $AA $ZEN Zen
# COPY ZENTAG TO LOCAL ~/.zen/tag
echo "$AA" > ~/.zen/tag/${AAH}/_tag.uid # Nom du ZenTAG
echo "$ZEN" > ~/.zen/tag/${AAH}/_tag.zen # Tag ZEN amount
echo "${IPFSNODEID}" > ~/.zen/tag/${AAH}/_ipfs.node.creator # NODE IPFS ID
echo "${ipfsnodeid}" > ~/.zen/tag/${AAH}/_ipfs.node.creator # NODE IPFS ID
echo "$TXHASH" > ~/.zen/tag/${AAH}/_g1.txhash # HASH G1 TX/IN
echo "$NODE_G1PUBKEY" > ~/.zen/tag/${AAH}/_g1.node.creator # CREATOR IPFS NODE G1PUBKEY
echo "$g1pub" > ~/.zen/tag/${AAH}/_g1.node.creator # CREATOR IPFS NODE G1PUBKEY
echo "$ISSUER" > ~/.zen/tag/${AAH}/_g1.issuer # TX ISSUER G1PUBKEY
########################################################################
# Create IPNS publishing key ${AA}.key
# =====================================
# BB encrypted version for IRL use
# NODE_G1PUBKEY for current G1SSB Node later access...
# g1pub for current G1SSB Node later access...
# Using sha512sum / openssl / natools.py (libsodium)
########################################################################
[[ ! -f ~/.ipfs/keystore/${AA}.key ]] && J=$(ipfs key gen -t rsa -s 2048 ${AA}.key)
@ -140,12 +140,12 @@ echo "$BBH" > ~/.zen/tag/${AAH}/_tag.BB.sha
# BB pgp symetric publishkey
openssl aes-256-cbc -pbkdf2 -k "$BB" -salt -in ~/.ipfs/keystore/${AA}.key -out ~/.zen/tag/${AAH}/_ipfs.publishkey.BB.aes
# GIVE IPFS CREATOR NODE ACCESS TO ZEN TAG
$MY_PATH/tools/natools.py encrypt -p $NODE_G1PUBKEY -i ~/.ipfs/keystore/${AA}.key -o ~/.zen/tag/${AAH}/_ipfs.publishkey.crypt
$MY_PATH/tools/natools.py encrypt -p $g1pub -i ~/.ipfs/keystore/${AA}.key -o ~/.zen/tag/${AAH}/_ipfs.publishkey.crypt
# LOG
echo "
CYPHERING PUBLISH KEY
__ _
_/_/ __/|_ __/|_ | |
/ / | / | / / /
/ / /_ __| /_ __| / /
@ -157,7 +157,7 @@ BBH : $BBH
"
#######################################################################
# PASSENGER FILE is added to IPFS then link is cyphered
#
# https://beechat.network/how-beechats-encryption-works/
if [[ -f $PASSENGER ]]; then
echo "
_ _ _ _ _ _ _ _ _
@ -167,14 +167,14 @@ echo "
"
# ADD PASSENGER TO IPFS
IPASSENGER=$(ipfs add -q $PASSENGER -w | tail -n 1)
IPASSENGER=$(ipfs add -q "$PASSENGER" -w | tail -n 1)
echo "$IPASSENGER" > ~/.zen/tag/${AAH}/_passenger.ipfs
# GET FILE NAME
PASSENGERNAME=$(basename -- "$PASSENGER")
echo "$PASSENGERNAME" > ~/.zen/tag/${AAH}/_passenger.filename
# G1SSB NODE ACCESS
$MY_PATH/tools/natools.py encrypt -p $NODE_G1PUBKEY -i ~/.zen/tag/${AAH}/_passenger.ipfs -o ~/.zen/tag/${AAH}/_passenger.ipfs.crypt
$MY_PATH/tools/natools.py encrypt -p $g1pub -i ~/.zen/tag/${AAH}/_passenger.ipfs -o ~/.zen/tag/${AAH}/_passenger.ipfs.crypt
# BB OWNER ACCESS
openssl aes-256-cbc -pbkdf2 -k "$BB" -salt -in ~/.zen/tag/${AAH}/_passenger.ipfs -out ~/.zen/tag/${AAH}/_passenger.ipfs.BB.aes
# CLEAN CLEARTEXT IPFS link
@ -194,11 +194,12 @@ _passenger.ipfs : $IPASSENGER
# # # ###### # # # # #
# # # # # # # # # #
###### #### # # ##### ###### #####
##################################################################
# Decode _passenger.ipfs with BB Passphrase
# DECODE AND READ _passenger.ipfs with BB Passphrase
##################################################################
openssl aes-256-cbc -pbkdf2 -k \"$BB\" -d -salt -in ~/.zen/tag/${AAH}/_passenger.ipfs.BB.aes -out /tmp/_passenger.ipfs
ipfs get -o /tmp /ipfs/$IPASSENGER/$PASSENGERNAME && vlc /tmp/$PASSENGERNAME 2>/dev/null
ipfs get -o /tmp \"/ipfs/$IPASSENGER/$PASSENGERNAME\" && vlc \"/tmp/$PASSENGERNAME\" 2>/dev/null
READ : $READ Zen
PARK : $PARK Zen
@ -240,8 +241,11 @@ J=$(ipfs name publish -k ${AA}.key --quieter /ipfs/${I})
echo "${J}" > ~/.zen/tag/${AAH}/_ipns
# INDEXING ZenTag to SWARM
mkdir -p ~/.zen/ipfs/.$IPFSNODEID/TAG/${J}
echo "${AA}" > ~/.zen/ipfs/.$IPFSNODEID/TAG/${J}/_tag.uid
mkdir -p ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}
echo "${AA}" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}/_tag.uid
# TODO add METADATA
# echo "" > ~/.zen/ipfs/.$ipfsnodeid/TAG/${J}/_tag.metadata.json
IWALLETS=$(ipfs add -rHq ~/.zen/ipfs | tail -n 1)
NODEIPNS=$(ipfs name publish --quieter /ipfs/$IWALLETS)
@ -255,7 +259,7 @@ echo "
$I
ZenTAG : ipfs ls /ipns/$J
NODE index : ipfs ls /ipns/$NODEIPNS/.$IPFSNODEID
NODE index : ipfs ls /ipns/$NODEIPNS/.$ipfsnodeid
"
########################################################################
@ -272,20 +276,20 @@ qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.read.png "RJ:${AA}#${J}"
# WRITE QRCODE
qrencode -s 5 -o ~/.zen/tag/${AAH}/_QRCODE.write.png "BJ:${BB}#${J}"
echo "DONE !!
echo "CREATED !!
${AA}"
########################################################################
# SBOT PUBLISH
########################################################################
echo '
__ _ ____
(_ |_)/ \|
__)|_)\_/|
__)|_)\_/| POST
'
sbotc publish '{"type":"post","text":"ZenTAG created"}'
sbotc publish '{"type":"post","text":"ZenTAG created : ipfs ls /ipns/$J"}'
########################################################################
@ -298,7 +302,7 @@ echo "
ipfs pin ls -q --type recursive | xargs ipfs pin rm && ipfs repo gc
rm -f ~/.ipfs/keystore/*.key
rm -Rf ~/.zen/tag/*
rm -Rf ~/.zen/ipfs/.$IPFSNODEID/TAG
rm -Rf ~/.zen/ipfs/.$ipfsnodeid/TAG
##################################################################"
########################################################################
exit 0

View File

@ -34,9 +34,9 @@ QWRITE="$2"
##############################################
# NODE ENVIRONEMENT DETECTION
##############################################
IPFSNODEID=$(ipfs id -f='<id>\n')
ipfsnodeid=$(ipfs id -f='<id>\n')
[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh
NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
g1pub=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2)
###############################################################
# ZenTag READ Passenger with ZenTag WRITE