added systemc unit file and cleaned script up

This commit is contained in:
bfogt 2018-11-25 20:03:46 -06:00
parent f154492fc2
commit b739e984ee
2 changed files with 127 additions and 128 deletions

View File

@ -2,20 +2,14 @@
#A tool to install AMBE server. #A tool to install AMBE server.
#This is essentially a scripted version of: #This is essentially a scripted version of:
#https://github.com/LX3JL/xlxd/blob/master/ambed/readme #https://github.com/LX3JL/xlxd/blob/master/ambed/readme
#Step 1: Install Debian 8 or 9 and make sure it has internet and is up to date. #Step 1: Install Debian 9.x and make sure it has internet and is up to date.
#Step 2: Plug AMBE Chip(s) into computer. #Step 2: Plug AMBE Chip(s) into computer.
#Step 3: Run this script on the computer with the ambe chips. #Step 3: Run this script on the computer with the ambe chips.
#Step 4: Reboot #Step 4: Reboot after installation.
#Step 5: Execute /ambed/run # systemctl status ambed #to show the status
#"To start your AMBE server manually, start a screen session. Just type 'screen' " # systemctl stop ambed #to stop ambed
#"cd /ambe " # systemctl start ambed #to start ambed
#"./run " # ambed logs are part of /var/log/messages
#"Leave screen session running"
#
#"To stop AMBE...."
#"ps aux | grep ambe"
#"kill <THE PID #>,Thats the official step for now"
#Lets begin------------------------------------------------------------------------------------------------- #Lets begin-------------------------------------------------------------------------------------------------
WHO=$(whoami) WHO=$(whoami)
#Have to be ROOT to run this script #Have to be ROOT to run this script
@ -31,11 +25,11 @@ if [ ! -e "/etc/debian_version" ]
then then
echo "" echo ""
echo "This script is only tested in Debian 8,9 and x64 cpu Arch. for now." echo "This script is only tested in Debian 8,9 and x64 cpu Arch. for now."
#echo "This script is only tested in Debian 8,9 and Raspian Stretch for now."
exit 0 exit 0
fi fi
#Gather variables #Gather variables
DIRDIR=$(pwd)
LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}') LOCAL_IP=$(ip a | grep inet | grep "eth0\|en" | awk '{print $2}' | tr '/' ' ' | awk '{print $1}')
ARC=$(lscpu | grep Arch | awk '{print $2}') ARC=$(lscpu | grep Arch | awk '{print $2}')
X64=http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-x86_64-1.4.6.tgz X64=http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-x86_64-1.4.6.tgz
@ -43,7 +37,7 @@ X32=http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-i386-1.4.6.tgz
#ARM=http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v7-hf-1.4.8.gz #ARM=http://www.ftdichip.com/Drivers/D2XX/Linux/libftd2xx-arm-v7-hf-1.4.8.gz
#Install dependicies #Install dependicies
echo "" echo "------------------------------------------------------------------------------"
echo "Installing required software..." echo "Installing required software..."
apt-get -y install wget apt-get -y install wget
apt-get -y install git apt-get -y install git
@ -54,12 +48,13 @@ apt-get -y install build-essential
#Make Directories and get the FTDI driver. #Make Directories and get the FTDI driver.
mkdir -p /ambed mkdir -p /ambed
mkdir -p /root/ambed-install-files mkdir -p /root/reflector-install-files/ambed
if [ ! -e /usr/local/lib/libftd2xx.so ] if [ ! -e /usr/local/lib/libftd2xx.so ]
then then
echo "" echo ""
echo "------------------------------------------------------------------------------"
echo "Downloading driver and installing it....." echo "Downloading driver and installing it....."
cd /root/ambed-install-files cd /root/reflector-install-files/ambed
if [ "$ARC" = "x86_64" ] if [ "$ARC" = "x86_64" ]
then then
wget $X64 wget $X64
@ -77,18 +72,18 @@ then
ln -sf /usr/local/lib/libftd2xx.so.1.4.6 /usr/local/lib/libftd2xx.so ln -sf /usr/local/lib/libftd2xx.so.1.4.6 /usr/local/lib/libftd2xx.so
fi fi
else else
echo "" echo "------------------------------------------------------------------------------"
echo "It looks like the driver is already installed. If this is wrong, see what '/usr/local/lib/libftd2xx.so' is up to. Skipping FTDI Driver install. " echo "It looks like the driver is already installed. If this is wrong, see what '/usr/local/lib/libftd2xx.so' is up to. Skipping FTDI Driver install. "
fi fi
#Time to get the xlx/ambe software from git #Time to get the xlx/ambe software from git
echo "" echo "------------------------------------------------------------------------------"
echo "Getting xlx/ambed from github..." echo "Getting xlx/ambed from github..."
cd /root/ambed-install-files cd /root/reflector-install-files/ambed
git clone https://github.com/LX3JL/xlxd.git git clone https://github.com/LX3JL/xlxd.git
echo "" echo "------------------------------------------------------------------------------"
echo "Installing ambed....." echo "Installing ambed....."
cd xlxd/ambed/ cd /root/reflector-install-files/ambed/xlxd/ambed/
make clean make clean
make make
make install make install
@ -99,30 +94,22 @@ then
echo "/ambe directory exists already, I dont need to add it." echo "/ambe directory exists already, I dont need to add it."
exit 0 exit 0
fi fi
echo "------------------------------------------------------------------------------"
echo "Copying ambed files and systemd files... "
cp ambed /ambed cp ambed /ambed
cp run /ambed cp $DIRDIR/templates/ambed.service /etc/systemd/system/
chmod 755 /ambed/run sed -i "s/LOCAL-IP/$LOCAL_IP/g" /etc/systemd/system/ambed.service
sed -i "s/127.0.0.1/$LOCAL_IP/g" /ambed/run systemctl daemon-reload
sed -i "s/sudo//g" /ambed/run
#That should be it for the install. #That should be it for the install.
echo "************************************************************************"
echo ""
echo ""
echo "To start your AMBE Server, start a screen session. Just type 'screen' "
echo "cd /ambe "
echo "./run "
echo "Leave screen session running"
echo ""
echo ""
echo "To stop AMBE...."
echo "ps aux | grep ambe"
echo "kill <THE PID #>"
echo "" echo ""
echo "" echo ""
echo "************************************************************************" echo "************************************************************************"
echo "" echo ""
echo "" echo ""
echo "After reading the above, reboot the server and you should be ready to start ambeD :) " echo " The install is complete. "
echo " Now reboot the server. "
echo " Use 'systemctl status ambed' to check the status. "
echo " ambed logs are part of /var/log/messages. "
echo "" echo ""
echo "" echo ""
echo "************************************************************************"

12
templates/ambed.service Normal file
View File

@ -0,0 +1,12 @@
[Unit]
Description=AMBED
[Service]
Type=simple
ExecStartPre=-/sbin/rmmod ftdi_sio
ExecStartPre=-/sbin/rmmod usbserial
ExecStart=/ambed/ambed LOCAL-IP
[Install]
WantedBy=multi-user.target
Alias=xlxd.service