paul- wrote:
> The /opt directory is supposed to be
>
> root:staff owned
> 775 + suid bit on the group.
Thanks @paul-.
I'm just wondering if there would be any harm in always running the
ngrok setup script with sudo so that it will succeed when people have
managed to alter their standard pCP ownerships/permissions? Here's the
code:
Code:
--------------------
#!/bin/sh
uuid=abc123
token=def456
srvip=192.168.1.1:9000
uname=phil
pswd=blablabla
nickname=pcp
region=us
packagename=ngrok
workingdir=~/$packagename
rootpath=$workingdir/usr/local/bin
tcz=~/$packagename.tcz
echo -e "\n--> Setting up ngrok to enable secure cloud access to LMS for the
MediaServer and/or LMS-lite skills\n"
mkdir -p $rootpath
echo -e "\n--> Fetching 64-bit ngrok tgz\n"
archive=$packagename.tgz
wget -q https://bin.equinox.io/c/4VmDzA7iaHb/ngrok-stable-linux-arm64.tgz -O
$archive
echo -e "\n--> Extracting ngrok from tar archive"
tar -x -f $archive -C $rootpath
echo -e "\n--> Fetching squashfs-tools\n"
tce-load -w squashfs-tools.tcz
tce-load -i squashfs-tools.tcz
echo -e "\n--> Making ngrok tcz package\n"
mksquashfs $workingdir/ $tcz
echo -e "\n--> Tidying up:\n"
rm $archive
rm -Rf $workingdir/
echo -e "--> Moving ngrok tcz package into tce/optional\n"
TCEMNT="/mnt/$(readlink /etc/sysconfig/tcedir | cut -d '/' -f3)"
mv $tcz $TCEMNT/tce/optional
echo -e "--> Loading ngrok.tcz for availability without restart\n"
tce-load -i ngrok.tcz
echo -e "\n--> Adding ngrok tcz package to tce/onboot.lst so that it is
available at boot\n"
sed -i "/^$packagename.tcz/d" $TCEMNT/tce/onboot.lst
echo $packagename.tcz >> $TCEMNT/tce/onboot.lst
echo -e "--> Fetching autostart script from smartskills.tech\n"
wget -q https://smartskills.tech/downloads/ngrok_startup.sh -O
/home/tc/ngrok_startup.sh
sed -i 's/^TUNNELNAME="..."/TUNNELNAME="pcp"/' /home/tc/ngrok_startup.sh
sed -i
's/^UUID="..."/UUID="bed26d74d2e47a4c69765e85cc87377cdec999730095458e"/'
/home/tc/ngrok_startup.sh
chmod +x /home/tc/ngrok_startup.sh
echo -e "--> Adding autostart entry to /opt/bootlocal.sh\n"
sed -i '/^\/bin\/sh \/home\/tc\/ngrok/d' /opt/bootlocal.sh
sed -i '3 a/bin/sh /home/tc/ngrok_startup.sh &' /opt/bootlocal.sh
sed -i '4 a' /opt/bootlocal.sh
yml=~/.ngrok2/ngrok.yml
echo -e "--> Creating ngrok.yml in /home/tc/.ngrok2/ for tunnel [$nickname]\n"
mkdir -p ~/.ngrok2
echo "authtoken: $token" > $yml
echo "web_addr: 0.0.0.0:4040" >> $yml
echo "region: $region" >> $yml
echo "tunnels:" >> $yml
echo " $nickname:" >> $yml
echo " proto: http" >> $yml
echo " bind_tls: true" >> $yml
echo " inspect: false" >> $yml
echo " addr: $srvip" >> $yml
echo " auth: \"$uname:$pswd\"" >> $yml
echo -e "--> Backing up changes using pcp bu.\n"
pcp bu
sh ~/ngrok_startup.sh
--------------------
I tend to only use sudo when it's really necessary but this is the
second user who had this script fail due to a permissions error on a
'dirty' pCP install.
------------------------------------------------------------------------
philchillbill's Profile: http://forums.slimdevices.com/member.php?userid=68920
View this thread: http://forums.slimdevices.com/showthread.php?t=113966
_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins