From e74a76bfc8c0cf3f4394ea1d9046b446e38c847a Mon Sep 17 00:00:00 2001 From: qo-op Date: Sun, 17 May 2020 11:56:39 +0200 Subject: [PATCH] isLAN --- .install/ipfs_alone.sh | 16 +++++++++----- .install/loveland.sh | 49 +++++++++++++++++++----------------------- www/loveland.conf | 14 +++--------- 3 files changed, 36 insertions(+), 43 deletions(-) diff --git a/.install/ipfs_alone.sh b/.install/ipfs_alone.sh index 7d1433c..630931c 100644 --- a/.install/ipfs_alone.sh +++ b/.install/ipfs_alone.sh @@ -22,10 +22,13 @@ if [ "$EUID" -eq 0 ] else echo -e "${c_yellow}OK $USER, let's go!$c_"; fi -[[ -d ~/.ipfs ]] && echo "IPFS install exist, please remove backup before execute this script" && exit 1 +[[ -d ~/.ipfs ]] && echo "IPFS install exist! Please remove or backup before executing this script" && exit 1 echo -e "${c_yellow}Onboarding IPFS...$c_" +myIP=$(hostname -I | awk '{print $1}') +isLAN=$(echo $myIP | grep -E "/(^127\.)|(^192\.168\.)|(^10\.)|(^172\.1[6-9]\.)|(^172\.2[0-9]\.)|(^172\.3[0-1]\.)|(^::1$)|(^[fF][cCdD])/") + MACHINE_TYPE=`uname -m` [ ${MACHINE_TYPE} == 'x86_64' ] && curl -s https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-amd64.tar.gz -o $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update" [ ${MACHINE_TYPE:0:3} == 'arm' ] && curl -s https://dist.ipfs.io/ipfs-update/v1.5.2/ipfs-update_v1.5.2_linux-arm.tar.gz -o $MY_PATH/ipfs-update.tar.gz || err+="Download ipfs-update" @@ -50,11 +53,13 @@ sudo systemctl daemon-reload || err+="Restart IPFS" sudo systemctl enable ipfs || err+="Enable IPFS daemon" # INIT ipfs -ipfs init -p lowpower || exit 1 -# ipfs init -p server ## Uncomment for server infrastructure -sudo chown -R $USER:$USER ~/.ipfs || exit 1 +[[ $isLAN ]] && ipfs init -p lowpower \ +|| ipfs init -p server # ACTIVATE CONFIG OPTIONS +########################################### +### HYPER IMPORTANT !!!!!!! IMPORTANT +########################################### # PUBSUB ipfs config Pubsub.Router gossipsub # MAXSTORAGE @@ -66,9 +71,10 @@ ipfs config --json Experimental.Libp2pStreamMounting true ######### UPDATE BOOTSTRAP LIST ########### ipfs bootstrap rm --all -ipfs bootstrap add /dnsaddr/rec.copylaradio.com/tcp/4001/ipfs/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda +ipfs bootstrap add /dnsaddr/oasis.astroport.com/tcp/4001/ipfs/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda ipfs bootstrap add /ip4/51.15.166.54/tcp/4001/p2p/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda ipfs bootstrap add /ip6/fd42:feed:feed:feed::1/tcp/4001/p2p/Qmb6Gyy3KFWTxWh4v6fBeh5ANxAF6YAahWQtokmsNsqGda +########################################### sudo systemctl restart ipfs || err+="Restart IPFS daemon" diff --git a/.install/loveland.sh b/.install/loveland.sh index 1c41edb..d17f424 100755 --- a/.install/loveland.sh +++ b/.install/loveland.sh @@ -75,33 +75,6 @@ echo ' ' sudo apt-get install fail2ban nginx ssl-cert php-curl php-sqlite3 php-gd php-json php-xml php-mbstring php-fpm sqlite -y || err=1 -# CONFIG NGINX - LOVE LAND FRONTAL WEB PAGE -sudo cp -f /home/$YOU/.zen/astroport/www/loveland.conf /etc/nginx/conf.d/ - -PHPVERSION=$(ps auxf | grep php-fpm | grep -v -E 'color=auto|grep' | head -n 1 | grep -oP '(?<=\().*(?=\))' | awk -F '/' '{print $4}') -sudo sed -i "s/_PHPVERSION_/$PHPVERSION/g" /etc/nginx/conf.d/loveland.conf - -nodename=$(cat /etc/hostname) -echo "ENTER Station accessible Network name !!! Suggestion : $nodename" -read nodename -[[ $nodename == "" ]] && echo "Are you sure? Hit ENTER to keep $nodename)" && read nodename -[[ $nodename == "" ]] && nodename=$(cat /etc/hostname) - -sudo sed -i "s/_SERVERNAME_/$nodename/g" /etc/nginx/conf.d/loveland.conf - -echo "INSTALL LOVELand WebSite" -if [[ ! -L /var/www/loveland ]]; then - sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland -fi -sudo chmod -R 777 /var/www/loveland/jukebox/albumart -sudo chmod -R 777 /var/www/loveland/jukebox/prefs - -# Disabling default website -sudo rm -f /etc/nginx/sites-enabled/default - -sudo systemctl restart nginx || err=1 - - # KILL RUNNING OASIS kill -9 $(ps auxf --sort=+utime | grep -w oasis | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}') echo "REstarting OASIS with good $nodename & network config" @@ -136,6 +109,28 @@ fi sleep 5 +# CONFIG NGINX - LOVE LAND FRONTAL WEB PAGE +sudo cp -f /home/$YOU/.zen/astroport/www/loveland.conf /etc/nginx/conf.d/ + +PHPVERSION=$(ps auxf | grep php-fpm | grep -v -E 'color=auto|grep' | head -n 1 | grep -oP '(?<=\().*(?=\))' | awk -F '/' '{print $4}') +sudo sed -i "s/_PHPVERSION_/$PHPVERSION/g" /etc/nginx/conf.d/loveland.conf +sudo sed -i "s/_SERVERNAME_/$nodename/g" /etc/nginx/conf.d/loveland.conf +sudo sed -i "s/_PORT_/10010/g" /etc/nginx/conf.d/loveland.conf +sudo sed -i "s/_APPLI_//g" /etc/nginx/conf.d/loveland.conf + +echo "INSTALL LOVELand WebSite" +if [[ ! -L /var/www/loveland ]]; then + sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland +fi +sudo chmod -R 777 /var/www/loveland/jukebox/albumart +sudo chmod -R 777 /var/www/loveland/jukebox/prefs + +# Disabling default website +# sudo rm -f /etc/nginx/sites-enabled/default + +sudo systemctl restart nginx || err=1 + + if [[ $err ]]; then echo -e "${c_red}Installation de LOVELand bizarre??$c_" echo "PLEASE... POST YOUR ISSUE! https://git.p2p.legal/axiom-team/astroport/issues" diff --git a/www/loveland.conf b/www/loveland.conf index 7676d3f..a3cf8b6 100644 --- a/www/loveland.conf +++ b/www/loveland.conf @@ -1,9 +1,9 @@ server { - listen 80; - listen [::]:80; + listen _PORT_; + listen [::]:_PORT_; - root /var/www/loveland; + root /var/www/loveland/_APPLI_; server_name _SERVERNAME_; @@ -26,14 +26,6 @@ server { } } -# OASIS SSB TODO: NOT WORKING (cor problem) - location /oasis { - proxy_pass http://127.0.0.1:3000; - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $remote_addr; - } - - # IPFS GATEWAY PROXY location /ipfs { proxy_pass http://127.0.0.1:8080;