diff --git a/Makefile b/Makefile index 599deed..8c2975d 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,13 @@ INSTALLER=dist/installer.sh all: $(INSTALLER) $(BINARY): version.go - GOARCH=arm go build -ldflags="-w -s" -trimpath -o $(BINARY) + GOARCH=arm GOARM=7 go build -ldflags="-w -s" -o $(BINARY) version.go: go generate $(INSTALLER): $(BINARY) scripts/installer.sh - cp scripts/install.sh $@ + cp scripts/installer.sh $@ gzip -c $(BINARY) >> $@ + chmod +x $@ clean: rm -fr dist diff --git a/scripts/installer.sh b/scripts/installer.sh index 1f82f21..79d05b0 100755 --- a/scripts/installer.sh +++ b/scripts/installer.sh @@ -1,9 +1,12 @@ #!/bin/bash -SERVICE_NAME=proxy +set -e + +UNIT_NAME=proxy +BINARY=rmfake-proxy DESTINATION="/home/root/rmfakecloud" echo "" -echo "rmfakecloud proxy installer" +echo "rmFakeCloud proxy installer" echo "" @@ -12,10 +15,11 @@ echo "" function unpack(){ mkdir -p ${DESTINATION} - systemctl stop proxy || true + systemctl stop ${UNIT_NAME} || true # Find __ARCHIVE__ maker, read archive content and decompress it ARCHIVE=$(awk '/^__ARCHIVE__/ {print NR + 1; exit 0; }' "${0}") - tail -n+${ARCHIVE} "${0}" | gunzip > ${DESTINATION}/${SERVICE_NAME} + tail -n+${ARCHIVE} "${0}" | gunzip > ${DESTINATION}/${BINARY} + chmod +x ${DESTINATION}/${BINARY} } # marks all as unsynced so that they are not deleted @@ -30,7 +34,7 @@ workdir=$DESTINATION cat > $workdir/proxy.cfg < /etc/systemd/system/proxy.service < /etc/systemd/system/${UNIT_NAME}.service < csr.conf [ req ] @@ -140,8 +147,9 @@ if [ ! -f proxy.crt ]; then else echo "crt exists" fi +popd } -# Put your logic here (if you need) + function install_certificates(){ certdir="/usr/local/share/ca-certificates" certname=$certdir/ca.crt @@ -151,7 +159,7 @@ function install_certificates(){ update-ca-certificates --fresh fi mkdir -p $certdir - cp ca.crt $certdir/ + cp $DESTINATION/ca.crt $certdir/ update-ca-certificates --fresh } @@ -169,23 +177,24 @@ EOF } +function getproxy(){ + read -p "Enter your own cloud url: " url + echo $url +} + function doinstall(){ unpack generate_certificates install_certificates # install proxy - url=getproxy - installproxy.sh $url + url=$(getproxy) + install_proxyservice $url patch_hosts systemctl stop xochitl fixsync systemctl start xochitl } -function getproxy(){ - read -p "Enter your own cloud url: " url - echo $url -} case $1 in "uninstall" ) @@ -202,11 +211,23 @@ case $1 in if [ $# -lt 1 ]; then url=$(getproxy) fi - echo $url + install_proxyservice $url ;; * ) - echo "params" +cat <