forked from axiom-team/astroport
260 lines
11 KiB
Bash
Executable File
260 lines
11 KiB
Bash
Executable File
#!/bin/bash
|
|
########################################################################
|
|
# Author: Fred (support@qo-op.com)
|
|
# Version: 0.3
|
|
# 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##*/}"
|
|
########################################################################
|
|
YOU=$(ps auxf --sort=+utime | grep -w ipfs | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1) || er+=" ipfs daemon not running"
|
|
IPFSNODEID=$(ipfs id -f='<id>\n') || er+=" ipfs id problem"
|
|
WHOAMI=$(sbotc whoami | jq -r .id) || er+=" sbotc whoami problem"
|
|
[[ "$YOU" == "" || "$IPFSNODEID" == "" || "$WHOAMI" == "" ]] && echo "ERROR : $er " && exit 1
|
|
########################################################################
|
|
#### DO NOT RUN AS ROOT
|
|
[[ $USER == "root" ]] && echo "DO NOT RUN AS root!! Use regular USER with sudo AUTHORISATION" && exit 1
|
|
#### APACHE NOT SUPPORTED
|
|
is_apache_running=$(ps auxf --sort=+utime | grep -w apache | grep -v -E 'color=auto|grep' | tail -n 1 | cut -d " " -f 1);
|
|
[[ $is_apache_running ]] && echo "SORRY ONLY nginx is supported. EXIT" && exit 1
|
|
#### ARM / X64 NOT USED THERE
|
|
MACHINE_TYPE=`uname -m`
|
|
[ ${MACHINE_TYPE:0:3} == 'arm' ] && isARM="YES"
|
|
|
|
### UPDATE apt cache
|
|
sudo apt-get update
|
|
|
|
##################################
|
|
## INSTALL RAINBOW ASCII ;)
|
|
[[ ! $(which figlet) ]] && sudo apt install figlet -y
|
|
[[ ! $(which lolcat) ]] && sudo apt install lolcat -y
|
|
|
|
echo '
|
|
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
______ __ ____ ___
|
|
/ ____/___ ____ __ __/ / ____ _/ __ \____ _____/ (_)___
|
|
/ / / __ \/ __ \/ / / / / / __ `/ /_/ / __ `/ __ / / __ \
|
|
/ /___/ /_/ / /_/ / /_/ / /___/ /_/ / _, _/ /_/ / /_/ / / /_/ /
|
|
\____/\____/ .___/\__, /_____/\__,_/_/ |_|\__,_/\__,_/_/\____/
|
|
/_/ /____/
|
|
|
|
Multimedia Layer (https://www.copylaradio.com)
|
|
' | lolcat
|
|
## MULTIMEDIA
|
|
## VIDEO & AUDIO & PLAYLISTS ~/.zen/ DIR
|
|
mkdir -p ~/.zen/video
|
|
mkdir -p ~/.zen/audio
|
|
mkdir -p ~/.zen/playlists
|
|
|
|
######## YOUTUBE-DL ##########
|
|
if [[ ! $(which youtube-dl) ]]; then
|
|
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 chown $YOU /usr/local/bin/youtube-dl
|
|
fi
|
|
|
|
###############################
|
|
# MPD/MPC RompR AUDIO LAYER
|
|
###############################
|
|
if [[ ! $(which mpd) ]]; then
|
|
sudo apt-get install libid3-tools mpd mpc lame ffmpeg lsof lltag inotify-tools bc -y || err=1
|
|
sudo apt-get install lame sox libsox-fmt-mp3 eyed3 python-chardet imagemagick curl -y || err=1 #libav-tools unavailable on some system
|
|
sudo apt-get install ca-certificates git-core binutils rsync alsa-utils bc espeak mpg321 fuse atomicparsley -y || err=1
|
|
|
|
## CONFIG MPD
|
|
sudo cp -f /home/$YOU/.zen/astroport/.install/templates/copylaradio/mpd.conf /etc/mpd.conf
|
|
sudo sed -i "s/_USER_/$YOU/g" /etc/mpd.conf || err=1
|
|
mkdir ~/.config/mpd && sudo cp -f /etc/mpd.conf ~/.config/mpd/mpd.conf && sudo chown $YOU ~/.config/mpd/mpd.conf
|
|
|
|
## CHOWN mpd FILES STRUCTURE
|
|
sudo chown -R $YOU /var/lib/mpd/ /var/run/mpd /run/mpd /var/log/mpd
|
|
sudo service mpd restart || err=1
|
|
fi
|
|
|
|
### INSTALL NGINX
|
|
echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
_
|
|
____ ____ _(_)___ _ __
|
|
/ __ \/ __ `/ / __ \| |/_/
|
|
/ / / / /_/ / / / / /> <
|
|
/_/ /_/\__, /_/_/ /_/_/|_|
|
|
/____/
|
|
|
|
install
|
|
' | lolcat
|
|
|
|
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
|
|
|
|
[[ ! $(which nslookup) ]] && sudo apt-get install lolcat dnsutils -y
|
|
|
|
echo '++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
__ ___ _ ___
|
|
/ |/ /_ __ ____ ____ _____ ___ ___ (_)___/__ \
|
|
/ /|_/ / / / / / __ \/ __ `/ __ `__ \/ _ \ / / ___// _/
|
|
/ / / / /_/ / / / / / /_/ / / / / / / __/ / (__ )/_/
|
|
/_/ /_/\__, / /_/ /_/\__,_/_/ /_/ /_/\___/ /_/____/(_)
|
|
/____/
|
|
' | lolcat
|
|
|
|
myIP=$(hostname -I | awk '{print $1}' | head -n 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])/")
|
|
|
|
# Ask to the router its name (BOX DNS or system defined)
|
|
[[ -f /home/$YOU/.zen/astroport/zen/tools/nodename ]] && NODENAME=$(/home/$YOU/.zen/astroport/zen/tools/nodename) \
|
|
|| NODENAME=$(curl -s https://git.p2p.legal/axiom-team/astroport/raw/master/zen/tools/nodename | bash) ## RUNNING ALONE !!
|
|
|
|
echo $NODENAME
|
|
|
|
######################################
|
|
### LAUNCHIN OASIS = SSB HTTP interface
|
|
######################################
|
|
echo '
|
|
_
|
|
____ ____ ______(_)____
|
|
/ __ \/ __ `/ ___/ / ___/
|
|
/ /_/ / /_/ (__ ) (__ )
|
|
\____/\__,_/____/_/____/
|
|
SSB DEMO HTTP interface
|
|
' | lolcat
|
|
# IN CASE, KILL RUNNING OASIS
|
|
isOASIS=$(ps auxf --sort=+utime | grep -w oasis | grep -v -E 'color=auto|grep' | tail -n 1 | awk '{print $2}')
|
|
[[ $isOASIS ]] && sudo kill -9 $isOASIS
|
|
|
|
echo "Starting OASIS with good $NODENAME & network config"
|
|
echo "TODO: add to your /etc/rc.local or systemd or initV !!!"
|
|
|
|
#if [[ ! $isLAN ]]; then
|
|
# ### TODO: unlock oasis restrictions!! CANNOT MAKE PRIVATE MESSAGE => Feddless.social CAN add it as module on loveland portal!!)
|
|
# oasis --allow-host $NODENAME --host $NODENAME --public 2>&1>/dev/null &
|
|
# echo "--public = OASIS STATION IS IN VIEWING MODE ONLY..."
|
|
#else
|
|
# oasis --allow-host $NODENAME --host $NODENAME 2>&1>/dev/null &
|
|
#fi
|
|
|
|
#sleep 5
|
|
|
|
echo '
|
|
__ ____ _ __________ __
|
|
/ / / __ \ | / / ____/ / ____ _____ ____/ /
|
|
/ / / / / / | / / __/ / / / __ `/ __ \/ __ /
|
|
/ /___/ /_/ /| |/ / /___/ /___/ /_/ / / / / /_/ /
|
|
/_____/\____/ |___/_____/_____/\__,_/_/ /_/\__,_/
|
|
|
|
Portal
|
|
' | lolcat
|
|
|
|
###
|
|
echo "INSTALL LOVELand WebSite. Linking to /var/www ..."
|
|
if [[ ! -L /var/www/loveland ]]; then
|
|
sudo ln -s /home/$YOU/.zen/astroport/www/LOVELand /var/www/loveland
|
|
fi
|
|
|
|
echo "JUKEBOX init"
|
|
[[ -d /var/www/loveland/jukebox/albumart ]] && sudo chmod -R 777 /var/www/loveland/jukebox/albumart
|
|
[[ -d /var/www/loveland/jukebox/prefs ]] && sudo chmod -R 777 /var/www/loveland/jukebox/prefs
|
|
[[ -d /var/www/loveland/g1barre/img/qrcodes ]] && sudo chmod -R 777 /var/www/loveland/g1barre/img/qrcodes
|
|
|
|
# CONFIG NGINX - LOVE LAND FRONTAL WEB PAGE
|
|
echo "$NODENAME" | figlet -f slant | lolcat
|
|
|
|
## Write NODENAME to IPFS
|
|
echo "$NODENAME" > /home/$YOU/.zen/ipfs/.$IPFSNODEID/G1SSB/_nodename
|
|
|
|
PHPVERSION=$(ps auxf | grep php-fpm | grep -v -E 'color=auto|grep' | head -n 1 | grep -oP '(?<=\().*(?=\))' | awk -F '/' '{print $4}')
|
|
### ASTROPORT STATION LOVELAND PORTAL
|
|
sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/loveland.conf > /tmp/loveland.conf
|
|
sudo sed -i "s/_MY_NODE_NAME_/$NODENAME/g" /tmp/loveland.conf
|
|
sudo sed -i "s/_PORT_/10010/g" /tmp/loveland.conf
|
|
sudo sed -i "s/_APPLI_//g" /tmp/loveland.conf
|
|
sudo cp -f /tmp/loveland.conf /etc/nginx/conf.d/loveland.conf
|
|
|
|
### GCHANGE G1 Zen
|
|
sudo rm -f /etc/nginx/conf.d/gchange.conf
|
|
sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/loveland.conf > /tmp/gchange.conf
|
|
sudo sed -i "s/_MY_NODE_NAME_/$NODENAME/g" /tmp/gchange.conf
|
|
sudo sed -i "s/_PORT_/10020/g" /tmp/gchange.conf
|
|
sudo sed -i "s/_APPLI_/gchange/g" /tmp/gchange.conf
|
|
sudo cp -f /tmp/gchange.conf /etc/nginx/conf.d/gchange.conf
|
|
|
|
### CESIUM G1 Zen
|
|
sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/loveland.conf > /tmp/cesium.conf
|
|
sudo sed -i "s/_MY_NODE_NAME_/$NODENAME/g" /tmp/cesium.conf
|
|
sudo sed -i "s/_PORT_/10030/g" /tmp/cesium.conf
|
|
sudo sed -i "s/_APPLI_/cesium/g" /tmp/cesium.conf
|
|
sudo cp -f /tmp/cesium.conf /etc/nginx/conf.d/cesium.conf
|
|
|
|
### JUKEBOX RompR CopyLaRadio
|
|
if [[ $(which mpd) ]]; then
|
|
sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/loveland.conf > /tmp/jukebox.conf
|
|
sudo sed -i "s/_MY_NODE_NAME_/$NODENAME/g" /tmp/jukebox.conf
|
|
sudo sed -i "s/_PORT_/10011/g" /tmp/jukebox.conf
|
|
sudo sed -i "s/_APPLI_/jukebox/g" /tmp/jukebox.conf
|
|
sudo cp -f /tmp/jukebox.conf /etc/nginx/conf.d/jukebox.conf
|
|
fi
|
|
|
|
### SSB OASIS Zen (PROXY MODE 10040 -> 3000)
|
|
if [[ $(which oasis) ]]; then
|
|
sudo sed "s/_MY_NODE_NAME_/$NODENAME/g" /home/$YOU/.zen/astroport/www/oasis.conf > /tmp/oasis.conf
|
|
sudo sed -i "s/_PORT_/10040/g" /tmp/oasis.conf
|
|
sudo sed -i "s/_LHOST_/$NODENAME:3000/g" /tmp/oasis.conf
|
|
sudo sed -i "s/_APPLI_//g" /tmp/oasis.conf
|
|
sudo cp -f /tmp/oasis.conf /etc/nginx/conf.d/oasis.conf
|
|
# TRICK: COULD BE USED TO ADD .htpasswod ACCESS CONTROL AND REMOVE --public
|
|
# TODO use "ipfs p2p" to AGREGATE ALL OASIS on ONE (not ALL like G1SMS) ?
|
|
# NEED G1PUB to be identified with same MEMBER owner in 'zen/ipfs_OPEN_ports.sh'?
|
|
fi
|
|
|
|
### G1SMS propagation to localhost:10099 / 10097 ("ipfs p2p" forwarded)
|
|
if [[ $(which gammu) ]]; then
|
|
# DIRECT MODE
|
|
sudo sed "s/_PHPVERSION_/$PHPVERSION/g" /home/$YOU/.zen/astroport/www/loveland.conf > /tmp/g1sms.conf
|
|
sudo sed -i "s/_MY_NODE_NAME_/$NODENAME/g" /tmp/g1sms.conf
|
|
sudo sed -i "s/_PORT_/10099/g" /tmp/g1sms.conf
|
|
sudo sed -i "s/_APPLI_/g1sms/g" /tmp/g1sms.conf
|
|
sudo cp -f /tmp/g1sms.conf /etc/nginx/conf.d/g1sms.conf
|
|
else
|
|
# PROXY MODE (10099 -> 10097) ### ipfs p2p PROPAGATION WITH 'zen/ipfs_OPEN_ports.sh'
|
|
sudo sed "s/_MY_NODE_NAME_/$NODENAME/g" /home/$YOU/.zen/astroport/www/oasis.conf > /tmp/g1sms_proxy.conf
|
|
sudo sed -i "s/_PORT_/10099/g" /tmp/g1sms_proxy.conf
|
|
sudo sed -i "s/_LHOST_/127\.0\.0\.1\:10097/g" /tmp/g1sms_proxy.conf
|
|
sudo sed -i "s/_APPLI_/g1sms/g" /tmp/g1sms_proxy.conf
|
|
sudo cp -f /tmp/g1sms_proxy.conf /etc/nginx/conf.d/g1sms_proxy.conf
|
|
fi
|
|
|
|
##### RESTART NGINX
|
|
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"
|
|
|
|
exit 1
|
|
else
|
|
|
|
echo -e "${c_green}LOVE Land a été installé avec succès$c_"
|
|
echo -e "LoveLand Portal link http://$NODENAME:10010 (TRY ME)
|
|
|
|
Add ScuttleButt Astroport PUB Invitation in http://$NODENAME:3000/settings
|
|
${c_light}oasis.astroport.com:8008::@UeiA9iqZ0/XTjmYBht230KGr44bsr+Tl5BXSUDFv8vo=.ed25519~jd9Z4y/d/xZCF7bfuSgQSiSGLMeWFhwMosKUFhFxeEY=" $c_
|
|
|
|
fi
|
|
|
|
# Open LOVEland in browser
|
|
URL="http://$NODENAME"
|
|
path=$(which xdg-open || which gnome-open)
|
|
|
|
xo ()
|
|
{
|
|
for var in "$@"; do
|
|
$path "$var";
|
|
sleep 0.5
|
|
done
|
|
}
|
|
|
|
[[ -n $path ]] && xo $URL:10010 $URL:10020 $URL:10030 > /dev/null
|
|
|
|
} # for script being completely downloaded before run
|