2019-12-24 05:47:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
################################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
|
|
|
################################################################################
|
|
|
|
# Activate SUPPORT MODE: open ssh over IPFS
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
2019-12-30 08:33:45 +01:00
|
|
|
if [[ -f $MY_PATH/.profile ]]; then
|
|
|
|
source $MY_PATH/.profile
|
|
|
|
elif [[ -f $MY_PATH/../.profile ]]; then
|
|
|
|
source $MY_PATH/../.profile
|
|
|
|
else
|
|
|
|
echo -e "${c_red}Le .profile n'existe pas$c_"
|
|
|
|
exit 1
|
|
|
|
fi
|
2019-12-29 15:17:57 +01:00
|
|
|
cd $GPATH
|
2019-12-24 05:47:47 +01:00
|
|
|
|
2019-12-29 15:08:27 +01:00
|
|
|
if [[ "$USER" != "root" ]]; then echo "Hey, $USER you must at least be admin of your system (sudo $0)"; exit; fi
|
2019-12-29 15:17:57 +01:00
|
|
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
2020-01-01 07:11:38 +01:00
|
|
|
|
2019-12-29 15:17:57 +01:00
|
|
|
su $YOU -c "ipfs p2p close --all"
|
2020-01-01 07:11:38 +01:00
|
|
|
su $YOU -c "ipfs p2p listen /x/ssh /ip4/127.0.0.1/tcp/22"
|
|
|
|
su $YOU -c "ipfs p2p listen /x/http /ip4/127.0.0.1/tcp/80"
|
|
|
|
su $YOU -c "ipfs p2p listen /x/https /ip4/127.0.0.1/tcp/443"
|
|
|
|
$(su $YOU -c "ipfs p2p ls")
|
2019-12-24 05:47:47 +01:00
|
|
|
|
2020-01-01 07:11:38 +01:00
|
|
|
echo "==================================
|
|
|
|
CONNECT TO XPORT = ssh, http, https
|
|
|
|
XPORT=ssh
|
|
|
|
LOCALPORT=$((10000 + RANDOM % 64000))
|
|
|
|
ipfs p2p forward /x/$XPORT /ip4/127.0.0.1/tcp/$LOCALPORT /ipfs/$IPFSNODEID"
|