move tmp scripts to this branch for reference
This commit is contained in:
parent
d418826c70
commit
6786a05a67
4 changed files with 235 additions and 0 deletions
92
scripts/docker-build.sh
Normal file
92
scripts/docker-build.sh
Normal file
|
@ -0,0 +1,92 @@
|
|||
#!/bin/bash
|
||||
|
||||
# see https://people.debian.org/~stapelberg/2015/07/27/dh-make-golang.html
|
||||
|
||||
GIT_HOST="git.aliberksandikci.com.tr"
|
||||
GIT_ORG="liderahenk"
|
||||
GIT_REPO="ahenk-go"
|
||||
FULL_URL="https://$GIT_HOST/$GIT_ORG/$GIT_REPO"
|
||||
DEV_NAME="Aliberk Sandıkçı"
|
||||
GIT_MAIL="git@aliberksandikci.com.tr"
|
||||
|
||||
UPLOAD_URL="127.0.0.1"
|
||||
UPLOAD_PORT="8000"
|
||||
|
||||
echo "Editing git configs..."
|
||||
git config --global init.defaultBranch main
|
||||
git config --global user.name "$DEV_NAME"
|
||||
git config --global user.email $GIT_MAIL
|
||||
git config --global color.status auto
|
||||
git config --global color.branch auto
|
||||
git config --global color.interactive auto
|
||||
git config --global color.diff auto
|
||||
|
||||
mkdir /build
|
||||
cd /build || exit
|
||||
|
||||
if [[ "$1" != "update" ]]; then
|
||||
|
||||
dh-make-golang make -allow_unknown_hoster "$GIT_HOST/$GIT_ORG/$GIT_REPO"
|
||||
|
||||
if [[ ! ("$1" != "notodo" || "$2" != "notodo") ]]; then
|
||||
|
||||
# TODO Add option to disable writing all these files all the time (-s --skip)
|
||||
nano "itp-$GIT_REPO.txt"
|
||||
sendmail -t <"itp-$GIT_REPO.txt"
|
||||
|
||||
cd $GIT_REPO || exit
|
||||
grep --color=always -r TODO debian
|
||||
echo -e "\nThese files needs review. Starting reviewing automatically in 10sec...\n"
|
||||
sleep 10
|
||||
# TODO Allow users to escape from automatic review and manually do it while in this script
|
||||
|
||||
while [[ $(grep -r TODO debian | wc --lines) -ne 0 ]]; do
|
||||
nano "$(grep -r TODO debian | awk '{sub(/:.*/,"")} NR==1')"
|
||||
|
||||
echo "Continuing from next file..."
|
||||
sleep 1
|
||||
grep --color=always -r TODO debian
|
||||
sleep 5
|
||||
|
||||
# TODO Allow user to reviewing remaining files, choosing between them, optional skipping, and waiting for an answer (continue? [Y/n])
|
||||
done
|
||||
echo "ALL FILES DONE"
|
||||
|
||||
dh_installsystemd
|
||||
echo """
|
||||
#!/usr/bin/make -f
|
||||
|
||||
%:
|
||||
dh \$@ --builddirectory=_build --buildsystem=golang --with=golang --with-systemd
|
||||
override_dh_auto_install:
|
||||
dh_auto_install -- --no-source
|
||||
""" >debian/rules
|
||||
sleep 5
|
||||
# FIXME Not working!
|
||||
|
||||
else
|
||||
cd $GIT_REPO || exit
|
||||
fi
|
||||
else
|
||||
gbp clone "$FULL_URL"
|
||||
cd $GIT_REPO || exit
|
||||
git checkout debian/sid
|
||||
pwd
|
||||
if [[ "$1" == "nmu" ]]; then
|
||||
dch --nmu
|
||||
else
|
||||
dch
|
||||
fi
|
||||
echo "Succesfully Updated deb package information"
|
||||
fi
|
||||
|
||||
# TODO ask user to continue
|
||||
|
||||
git add debian && git commit -a -m 'Initial packaging'
|
||||
|
||||
gbp buildpackage
|
||||
|
||||
cd ..
|
||||
lintian -- *.changes
|
||||
|
||||
echo -e "SOLVE LINTIAN ERRORS / WARNINGS\nAFTER THAT, PUSH REPO"
|
73
scripts/install.sh
Normal file
73
scripts/install.sh
Normal file
|
@ -0,0 +1,73 @@
|
|||
#!/bin/bash
|
||||
|
||||
### Ahenk Agent Local Installation Script
|
||||
### IMPORTANT NOTICE !
|
||||
# Consider to use makefile for building or .deb file for installing package,
|
||||
# using this scripts is not suggested anymore !
|
||||
|
||||
### --------------------- ###
|
||||
|
||||
### --> Prerequisites
|
||||
# git
|
||||
# go 1.20+
|
||||
# systemd
|
||||
|
||||
# wget -qO- https://git.aliberksandikci.com.tr/liderahenk/ahenk-go/raw/branch/main/scripts/install.sh | bash
|
||||
|
||||
### --> Variable Set
|
||||
REPO_NAME="ahenk-go"
|
||||
REPO_LINK="https://git.aliberksandikci.com.tr/liderahenk/${REPO_NAME}"
|
||||
DAEMON_NAME="ahenk-go"
|
||||
CONF_DIR="/etc/ahenk-go/"
|
||||
TEMP_DIR="$(mktemp -d)"
|
||||
MAIN_DIR="${TEMP_DIR}/${REPO_NAME}/"
|
||||
echo -e "VARIABLES SET\n"
|
||||
|
||||
|
||||
### --> Pre-Cleaning
|
||||
sudo rm /usr/bin/${DAEMON_NAME}
|
||||
sudo killall "$DAEMON_NAME"
|
||||
sudo systemctl disable "$DAEMON_NAME"
|
||||
sudo systemctl stop "$DAEMON_NAME"
|
||||
sudo systemctl daemon-reload
|
||||
sudo rm -rf "$CONF_DIR"
|
||||
sudo mkdir -p "$CONF_DIR"
|
||||
echo -e "PRE-CLENING DONE\n"
|
||||
|
||||
|
||||
### --> Building
|
||||
cd "$TEMP_DIR" || exit
|
||||
echo "$TEMP_DIR"
|
||||
git clone "$REPO_LINK"
|
||||
cd "$MAIN_DIR" || exit
|
||||
|
||||
# cmd/ahenkd-go
|
||||
cd cmd/ahenkd-go || exit
|
||||
sudo go build -o "/usr/bin/ahenkd-go"
|
||||
|
||||
echo -e "BUILDING DONE\n"
|
||||
|
||||
### --> Configurations
|
||||
sudo touch "$CONF_DIR/user.info"
|
||||
sudo cat << EOF | sudo tee -a "$CONF_DIR/user.info" > /dev/null
|
||||
The current working directory is: $PWD
|
||||
You are logged in as $(whoami)
|
||||
$HOME $USER $SUDO_USER
|
||||
EOF
|
||||
sudo chown root:root "$CONF_DIR/user.info"
|
||||
sudo chmod 640 "$CONF_DIR/user.info"
|
||||
echo -e "CONFIGURATIONS DONE\n"
|
||||
|
||||
### --> Installing
|
||||
if [[ $(ps -p 1 | awk 'FNR == 2 {print $4} ') == "systemd" ]]
|
||||
then
|
||||
sudo mv "${MAIN_DIR}build/package/deb/${DAEMON_NAME}.service" /etc/systemd/system/
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$DAEMON_NAME"
|
||||
sudo systemctl start "$DAEMON_NAME"
|
||||
echo -e "INSTALLING DONE\n"
|
||||
|
||||
### --> Post-Cleaning
|
||||
sudo rm -rf "$TEMP_DIR"
|
||||
echo -e "POST-CLEANING DONE\n"
|
3
scripts/local-build.sh
Normal file
3
scripts/local-build.sh
Normal file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
sudo go build -o "build/package/bin/ahenkd-go" cmd/ahenkd-go/ahenkd-go.go
|
67
scripts/local-install.sh
Normal file
67
scripts/local-install.sh
Normal file
|
@ -0,0 +1,67 @@
|
|||
#!/bin/bash
|
||||
|
||||
### Ahenk Agent Local Installation Script
|
||||
|
||||
### --> Prerequisites
|
||||
# go 1.20+
|
||||
# systemd
|
||||
|
||||
# Change directory to main repo (cd ahenk-go)
|
||||
# bash scripts/local-install.sh
|
||||
|
||||
### --> Variable Set
|
||||
REPO_NAME="ahenk-go"
|
||||
DAEMON_NAME="ahenk-go"
|
||||
CONF_DIR="/etc/ahenk-go/"
|
||||
TEMP_DIR="$(mktemp -d)"
|
||||
MAIN_DIR="${TEMP_DIR}/${REPO_NAME}/"
|
||||
echo -e "VARIABLES SET\n"
|
||||
|
||||
|
||||
### --> Pre-Cleaning
|
||||
sudo rm /usr/bin/${DAEMON_NAME}
|
||||
sudo killall "$DAEMON_NAME"
|
||||
sudo systemctl disable "$DAEMON_NAME"
|
||||
sudo systemctl stop "$DAEMON_NAME"
|
||||
sudo systemctl daemon-reload
|
||||
sudo rm -rf "$CONF_DIR"
|
||||
sudo mkdir -p "$CONF_DIR"
|
||||
echo -e "PRE-CLENING DONE\n"
|
||||
|
||||
|
||||
### --> Building
|
||||
cp -r ../ "$TEMP_DIR"
|
||||
cd "$TEMP_DIR" || exit
|
||||
echo "$TEMP_DIR"
|
||||
cd "$MAIN_DIR" || exit
|
||||
|
||||
# cmd/ahenkd-go
|
||||
cd cmd/ahenkd-go || exit
|
||||
sudo go build -o "/usr/bin/ahenkd-go"
|
||||
|
||||
echo -e "BUILDING DONE\n"
|
||||
|
||||
### --> Configurations
|
||||
sudo touch "$CONF_DIR/user.info"
|
||||
sudo cat << EOF | sudo tee -a "$CONF_DIR/user.info" > /dev/null
|
||||
The current working directory is: $PWD
|
||||
You are logged in as $(whoami)
|
||||
$HOME $USER $SUDO_USER
|
||||
EOF
|
||||
sudo chown root:root "$CONF_DIR/user.info"
|
||||
sudo chmod 640 "$CONF_DIR/user.info"
|
||||
echo -e "CONFIGURATIONS DONE\n"
|
||||
|
||||
### --> Installing
|
||||
if [[ $(ps -p 1 | awk 'FNR == 2 {print $4} ') == "systemd" ]]
|
||||
then
|
||||
sudo mv "${MAIN_DIR}debian/${DAEMON_NAME}.service" /etc/systemd/system/
|
||||
fi
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$DAEMON_NAME"
|
||||
sudo systemctl start "$DAEMON_NAME"
|
||||
echo -e "INSTALLING DONE\n"
|
||||
|
||||
### --> Post-Cleaning
|
||||
sudo rm -rf "$TEMP_DIR"
|
||||
echo -e "POST-CLEANING DONE\n"
|
Loading…
Reference in a new issue