diff --git a/.install/copylaradio.sh b/.install/copylaradio.sh new file mode 100755 index 0000000..c5595d2 --- /dev/null +++ b/.install/copylaradio.sh @@ -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 +} + +$@ diff --git a/.install/ipfs-pi-stream/audio.jpg b/.install/ipfs-pi-stream/audio.jpg new file mode 100644 index 0000000..9850d25 Binary files /dev/null and b/.install/ipfs-pi-stream/audio.jpg differ diff --git a/.install/ipfs-pi-stream/enable-camera.sh b/.install/ipfs-pi-stream/enable-camera.sh new file mode 100755 index 0000000..010c0b4 --- /dev/null +++ b/.install/ipfs-pi-stream/enable-camera.sh @@ -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" < "$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 diff --git a/.install/ipfs-pi-stream/install b/.install/ipfs-pi-stream/install new file mode 100755 index 0000000..571e541 --- /dev/null +++ b/.install/ipfs-pi-stream/install @@ -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="

IPFS Pi Stream Player

IPFS Video player for Pi Stream.
M3U8 Stream located over ipns
Go and play with built in video player
" +sudo sed -i "s#<\!--APPLIST-->#$APP\n<\!--APPLIST-->#" "/var/www/html/index.html" diff --git a/.install/ipfs-pi-stream/process-stream.service b/.install/ipfs-pi-stream/process-stream.service new file mode 100644 index 0000000..cd3166b --- /dev/null +++ b/.install/ipfs-pi-stream/process-stream.service @@ -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 diff --git a/.install/ipfs-pi-stream/process-stream.sh b/.install/ipfs-pi-stream/process-stream.sh new file mode 100755 index 0000000..53b92a0 --- /dev/null +++ b/.install/ipfs-pi-stream/process-stream.sh @@ -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 diff --git a/.install/ipfs-pi-stream/uninstall b/.install/ipfs-pi-stream/uninstall new file mode 100755 index 0000000..1c0a574 --- /dev/null +++ b/.install/ipfs-pi-stream/uninstall @@ -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 diff --git a/.install/ipfs.sh b/.install/ipfs.sh index 2c5761e..23b88b8 100755 --- a/.install/ipfs.sh +++ b/.install/ipfs.sh @@ -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 diff --git a/.install/scuttlebutt.sh b/.install/scuttlebutt.sh index c253608..5e3361d 100755 --- a/.install/scuttlebutt.sh +++ b/.install/scuttlebutt.sh @@ -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 < ~/.zen/run-ssb_$nodename.sh < ~/.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 < ~/.zen/run-ssb_$nodename.sh < ~/.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' !!! " } $@ diff --git a/.install/silkaj-php-mysql.sh b/.install/silkaj-php-mysql.sh new file mode 100755 index 0000000..4d3c023 --- /dev/null +++ b/.install/silkaj-php-mysql.sh @@ -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 diff --git a/.install/ssb-patchfoo/config b/.install/ssb-patchfoo/config new file mode 100644 index 0000000..ce61ea2 --- /dev/null +++ b/.install/ssb-patchfoo/config @@ -0,0 +1,7 @@ +{ + "plugins": { + "ssb-private": true, + "ssb-backlinks": true, + "patchfoo": true + } +} diff --git a/.install/ssb-patchfoo/install b/.install/ssb-patchfoo/install new file mode 100755 index 0000000..18ff427 --- /dev/null +++ b/.install/ssb-patchfoo/install @@ -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="

Patch Foo

Plain SSB web UI.
Go
" +sudo sed -i "s#<\!--APPLIST-->#$APP\n<\!--APPLIST-->#" "/var/www/html/index.html" + +# shellcheck disable=SC2164 +cd "$CURRENT_DIR" diff --git a/.install/ssb-patchfoo/ssb-patchfoo.conf b/.install/ssb-patchfoo/ssb-patchfoo.conf new file mode 100644 index 0000000..5ca513f --- /dev/null +++ b/.install/ssb-patchfoo/ssb-patchfoo.conf @@ -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; + } diff --git a/.install/ssl.sh b/.install/ssl.sh new file mode 100755 index 0000000..6eadd3f --- /dev/null +++ b/.install/ssl.sh @@ -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 "\ + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/doc/images/astroport7_roots.png b/doc/images/astroport7_roots.png new file mode 100644 index 0000000..f7840a8 Binary files /dev/null and b/doc/images/astroport7_roots.png differ diff --git a/doc/images/astroportlogo1.png b/doc/images/astroportlogo1.png new file mode 100644 index 0000000..a8e7d14 Binary files /dev/null and b/doc/images/astroportlogo1.png differ diff --git a/doc/images/astroportlogo2bis.png b/doc/images/astroportlogo2bis.png new file mode 100644 index 0000000..4493b4f Binary files /dev/null and b/doc/images/astroportlogo2bis.png differ diff --git a/doc/images/astroportlogo4color.png b/doc/images/astroportlogo4color.png new file mode 100644 index 0000000..a892f6b Binary files /dev/null and b/doc/images/astroportlogo4color.png differ diff --git a/doc/images/colors.gif b/doc/images/colors.gif new file mode 100644 index 0000000..b206197 Binary files /dev/null and b/doc/images/colors.gif differ diff --git a/doc/images/dothefive_90px.gif b/doc/images/dothefive_90px.gif new file mode 100644 index 0000000..cdef142 Binary files /dev/null and b/doc/images/dothefive_90px.gif differ diff --git a/doc/images/fork-the-future.jpg b/doc/images/fork-the-future.jpg new file mode 100644 index 0000000..814f180 Binary files /dev/null and b/doc/images/fork-the-future.jpg differ diff --git a/doc/images/living_worlds.gif b/doc/images/living_worlds.gif new file mode 100644 index 0000000..19004fd Binary files /dev/null and b/doc/images/living_worlds.gif differ diff --git a/doc/images/money_wizard.jpg b/doc/images/money_wizard.jpg new file mode 100644 index 0000000..643237f Binary files /dev/null and b/doc/images/money_wizard.jpg differ diff --git a/doc/images/sucram.jpg b/doc/images/sucram.jpg new file mode 100644 index 0000000..01e54e9 Binary files /dev/null and b/doc/images/sucram.jpg differ diff --git a/doc/message_fred.mp3 b/doc/message_fred.mp3 new file mode 100644 index 0000000..ee9cde3 Binary files /dev/null and b/doc/message_fred.mp3 differ diff --git a/doc/videos/The-Story-of-a-Rock.mp4 b/doc/videos/The-Story-of-a-Rock.mp4 new file mode 100644 index 0000000..9d55b20 Binary files /dev/null and b/doc/videos/The-Story-of-a-Rock.mp4 differ diff --git a/install.sh b/install.sh index 1a04ec2..a8fecc2 100755 --- a/install.sh +++ b/install.sh @@ -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 ? # -------------------------------------------- diff --git a/www/rompr.conf b/www/rompr.conf index aa1ec8d..08d664f 100644 --- a/www/rompr.conf +++ b/www/rompr.conf @@ -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; +} + } diff --git a/www/ssb-frontpage/index.html b/www/ssb-frontpage/index.html new file mode 100644 index 0000000..8d6d8ea --- /dev/null +++ b/www/ssb-frontpage/index.html @@ -0,0 +1,71 @@ + + + Patchwork Invite + + + + + +
+ +
+

Hi, {recipient}!

+

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.

+

Because it's so radically different (like, it's not actually on the web) it takes a few steps to get started, which i've helpfully included below!

+

How to Join Scuttlebutt, and How to Find Me on The Network:

+
    +
  1. Download Patchwork, a client for navigating Scuttlebutt.
  2. +

    Scuttlebutt is a method 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:

    + +
  3. Install and start up The Patchwork application.
  4. + + +
  5. Paste in a pub invite code.
  6. +

    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.

    +

    You can find me on this pub: {pub}

    +

    <And you can join by clicking 'join pub' and pasting in this invite code:

    +

    {invite-code}

    + +
  7. Hang out for a sec as you are synced up with the network.
  8. + + +

    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!

    +

    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.

    +

    While you wait, check out this video that better explains how Scuttlebutt works, through the context of a *~*~love story*~*~:

    + +
  9. Find Me and Friend Me.
  10. +

    My name on here is {username}.

    +

    But you should find me using my public key, which is:

    +

    {public-key}

    +

    The public key is sort of like my techno-signature, so you know that the person you are friending is actually me.

    +

    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.

    + +
  11. Say Hi!
  12. +

    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.

    +
    +

    To send me a private message, click private, then add my @name and say hi!

    + +

    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)

    + + +
  13. Check out these other channels.
  14. +

    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!

    +
      +
    • {channel-one}
    • +
    • {channel-two}
    • +
    • {channel-three}
    • +
    +
+
+

I'm excited to talk to you through Scuttlebutt! Let me know if you have any problems starting up!

+

- {sender}

+
+
+
+ diff --git a/www/ssb-frontpage/stylesheet.css b/www/ssb-frontpage/stylesheet.css new file mode 100644 index 0000000..3abc75d --- /dev/null +++ b/www/ssb-frontpage/stylesheet.css @@ -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; } diff --git a/zen/functions.sh b/zen/functions.sh index da6144b..3e97e1e 100755 --- a/zen/functions.sh +++ b/zen/functions.sh @@ -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 -} diff --git a/zen/g1_TX2ZEN.sh b/zen/g1_SURVEY.sh similarity index 60% rename from zen/g1_TX2ZEN.sh rename to zen/g1_SURVEY.sh index a90825c..c2abc29 100755 --- a/zen/g1_TX2ZEN.sh +++ b/zen/g1_SURVEY.sh @@ -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='\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 diff --git a/zen/g1ssb_ENV.sh b/zen/g1ssb_ENV.sh deleted file mode 100755 index e87ac6c..0000000 --- a/zen/g1ssb_ENV.sh +++ /dev/null @@ -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='\n') -[[ ! -f ~/.ssb/secret.dunikey ]] && $MY_PATH/tools/secret2dunikey.sh -NODE_G1PUBKEY=$(cat ~/.ssb/secret.dunikey | grep 'pub:' | cut -d ' ' -f 2) diff --git a/zen/ssb_INIT.sh b/zen/ssb_INIT.sh index 6e34434..0efc139 100755 --- a/zen/ssb_INIT.sh +++ b/zen/ssb_INIT.sh @@ -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='\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='\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 < ~/.zen/run-ssb-PUB_$EXTERNAL.sh < ~/.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... diff --git a/zen/ssb_SURVEY_contact.sh b/zen/ssb_SURVEY_contact.sh new file mode 100755 index 0000000..ff7fdfb --- /dev/null +++ b/zen/ssb_SURVEY_contact.sh @@ -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='\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") diff --git a/zen/ssb_SURVEY_swarmkey.sh b/zen/ssb_SURVEY_swarmkey.sh new file mode 100755 index 0000000..e2f109e --- /dev/null +++ b/zen/ssb_SURVEY_swarmkey.sh @@ -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='\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") diff --git a/zen/tools/duniter_getnode.sh b/zen/tools/duniter_getnode.sh index 34fc78e..ee64230 100755 --- a/zen/tools/duniter_getnode.sh +++ b/zen/tools/duniter_getnode.sh @@ -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 diff --git a/zen/zen_MAKE.sh b/zen/zen_MAKE.sh index 1a90345..cfb646d 100755 --- a/zen/zen_MAKE.sh +++ b/zen/zen_MAKE.sh @@ -28,11 +28,11 @@ PARK="$5" # Zen amount payed for IPFS PIN by passenger everyday ############################################## # NODE ENVIRONEMENT DETECTION ############################################## -IPFSNODEID=$(ipfs id -f='\n') +ipfsnodeid=$(ipfs id -f='\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 diff --git a/zen/zen_PASSENGER_READ.sh b/zen/zen_PASSENGER_READ.sh index 8fe6138..587951b 100755 --- a/zen/zen_PASSENGER_READ.sh +++ b/zen/zen_PASSENGER_READ.sh @@ -34,9 +34,9 @@ QWRITE="$2" ############################################## # NODE ENVIRONEMENT DETECTION ############################################## -IPFSNODEID=$(ipfs id -f='\n') +ipfsnodeid=$(ipfs id -f='\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