Academia JavaEE Workspace in Raspbian: Difference between revisions
Jump to navigation
Jump to search
Created page with "==Java== apt install openjdk-8-jdk-headless apt install nodejs apt install maven apt install npm apt install ant ==PostgreSQL== ===Install=== <source lang="bash"> apt in..." |
|||
| (31 intermediate revisions by the same user not shown) | |||
| Line 8: | Line 8: | ||
==PostgreSQL== | ==PostgreSQL== | ||
===Install=== | ===Install=== | ||
apt install postgresql postgresql-contrib | |||
apt install postgresql postgresql-contrib | sudo su; su - postgres | ||
createuser | |||
createdb | createuser '''postgres'''; createdb '''postgres''' | ||
createuser '''root'''; createdb '''root''' | |||
createuser '''pi'''; createdb '''pi''' | |||
exit; exit | |||
===Schema=== | ===Schema=== | ||
< | <syntaxhighlight lang="sql"> | ||
-- sudo su; su - postgres; psql | |||
CREATE DATABASE academia; | CREATE DATABASE academia; | ||
CREATE USER academia WITH ENCRYPTED PASSWORD 'academia'; | CREATE USER academia WITH ENCRYPTED PASSWORD 'academia'; | ||
GRANT ALL PRIVILEGES ON DATABASE academia TO academia; | GRANT ALL PRIVILEGES ON DATABASE academia TO academia; | ||
</ | </syntaxhighlight> | ||
sudo su; su - postgres | |||
psql academia < academia.sql | psql academia < academia.sql | ||
psql -h db00.chorke.org -p 5432 -d academia -U academia | psql -h db00.chorke.org -p 5432 -d academia -U academia | ||
| Line 27: | Line 31: | ||
===Delete=== | ===Delete=== | ||
< | <syntaxhighlight lang="sql"> | ||
-- sudo su; su - postgres; psql | |||
REVOKE CONNECT ON DATABASE academia FROM public; | REVOKE CONNECT ON DATABASE academia FROM public; | ||
SELECT pg_terminate_backend(pg_stat_activity.pid) | SELECT pg_terminate_backend(pg_stat_activity.pid) | ||
FROM pg_stat_activity | FROM pg_stat_activity | ||
WHERE pg_stat_activity.datname in ('academia'); | WHERE pg_stat_activity.datname in ('academia'); | ||
</ | </syntaxhighlight> | ||
sudo su; su - postgres | |||
ps -ef | grep postgres | ps -ef | grep postgres | ||
kill -9 PID | kill -9 PID | ||
< | <syntaxhighlight lang="sql"> | ||
-- sudo su; su - postgres; psql | |||
DROP DATABASE IF EXISTS academia; | DROP DATABASE IF EXISTS academia; | ||
</ | </syntaxhighlight> | ||
=== | ===PgAdmin4=== | ||
< | <syntaxhighlight lang="bash"> | ||
apt install curl | apt install curl | ||
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add | curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add | ||
| Line 48: | Line 55: | ||
/etc/apt/sources.list.d/pgadmin4.list && apt update' | /etc/apt/sources.list.d/pgadmin4.list && apt update' | ||
apt install pgadmin4-desktop | apt install pgadmin4-desktop | ||
</ | </syntaxhighlight> | ||
==Redis== | ==Redis== | ||
< | <syntaxhighlight lang="bash" highlight="13"> | ||
apt install redis-server | apt install redis-server | ||
nano /etc/redis/redis.conf | nano /etc/redis/redis.conf | ||
| Line 66: | Line 73: | ||
supervised systemd | supervised systemd | ||
END_COMMENT | END_COMMENT | ||
systemctl status | systemctl status redis-server | ||
</ | </syntaxhighlight> | ||
==Workspace== | ==Workspace== | ||
< | <syntaxhighlight lang="bash"> | ||
mkdir -p $HOME/chorke | mkdir -p $HOME/chorke | ||
mkdir -p /opt/dev/$USER/chorke/academia | mkdir -p /opt/dev/$USER/chorke/academia | ||
| Line 79: | Line 86: | ||
ls -lah $HOME/chorke | ls -lah $HOME/chorke | ||
nano ~/.bashrc | nano ~/.bashrc | ||
</ | </syntaxhighlight> | ||
==Editor== | ==Editor== | ||
< | <syntaxhighlight lang="bash"> | ||
sudo apt install apt-transport-https | sudo apt install apt-transport-https | ||
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - | wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add - | ||
| Line 88: | Line 95: | ||
sudo apt update;sudo apt install sublime-text | sudo apt update;sudo apt install sublime-text | ||
sudo snap install notepad-plus-plus | sudo snap install notepad-plus-plus | ||
</ | </syntaxhighlight> | ||
==Git SCM== | ==Git SCM== | ||
< | <syntaxhighlight lang="bash"> | ||
ssh-keygen -t rsa -b 4096 -C "email.id@academia.chorke.org" | ssh-keygen -t rsa -b 4096 -C "email.id@academia.chorke.org" | ||
: <<'END_COMMENT' | : <<'END_COMMENT' | ||
| Line 117: | Line 124: | ||
ls -lah ~/.ssh/ | ls -lah ~/.ssh/ | ||
cat < ~/.ssh/git_academia_chorke_org_rsa.pub | cat < ~/.ssh/git_academia_chorke_org_rsa.pub | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="bash"> | ||
nano ~/.ssh/config | nano ~/.ssh/config | ||
: <<'END_COMMENT' | : <<'END_COMMENT' | ||
| Line 128: | Line 135: | ||
User git | User git | ||
END_COMMENT | END_COMMENT | ||
</ | </syntaxhighlight> | ||
< | <syntaxhighlight lang="bash"> | ||
git config --global user.email "email.id@academia.chorke.org" | git config --global user.email "email.id@academia.chorke.org" | ||
git config --global user.name "FULL NAME" | git config --global user.name "FULL NAME" | ||
ssh -vT git.academia.chorke.org | ssh -vT git.academia.chorke.org | ||
</ | </syntaxhighlight> | ||
==Docker== | |||
<syntaxhighlight lang="bash"> | |||
cat <<'EXE' | sudo bash | |||
apt-get update | |||
apt-get install -y ca-certificates curl | |||
install -m 0755 -d /etc/apt/keyrings | |||
apt-get clean | |||
curl -fsSL https://download.docker.com/linux/debian/gpg| sudo tee /etc/apt/keyrings/docker.asc >/dev/null | |||
chmod a+r /etc/apt/keyrings/docker.asc | |||
DISTRIBUTION=$(. /etc/os-release && echo "${VERSION_CODENAME}") | |||
cat << SRC | sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null | |||
Types: deb | |||
Suites: ${DISTRIBUTION} | |||
Components: stable | |||
Signed-By: /etc/apt/keyrings/docker.asc | |||
URIs: https://download.docker.com/linux/debian | |||
SRC | |||
apt-get update | |||
apt-get remove -y $(dpkg --get-selections docker.io docker-compose docker-doc podman-docker containerd runc | cut -f1) | |||
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |||
apt-get clean | |||
systemctl enabled --start docker | |||
systemctl status docker | |||
systemctl start docker | |||
EXE | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
cat << EXE | sudo bash | |||
usermod -aG docker ${USER} | |||
echo 'id -nG'|sudo -i -u ${USER} bash | |||
echo 'docker ps -a'|sudo -i -u ${USER} bash | |||
EXE | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="yaml"> | |||
yq -o=json <<'YML'| \ | |||
sudo tee /etc/docker/daemon.json >/dev/null | |||
--- | |||
bip: 10.20.13.1/24 | |||
mtu: 1500 | |||
dns: | |||
- 1.1.1.1 | |||
- 8.8.8.8 | |||
debug: true | |||
YML | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
cat <<'EXE' | sudo bash | |||
systemctl stop docker.socket | |||
systemctl stop docker.service | |||
systemctl start docker.service | |||
EXE | |||
</syntaxhighlight> | |||
---- | |||
<syntaxhighlight lang="bash"> | |||
su - ${USER} | |||
docker run --rm alpine cat /etc/resolv.conf | |||
docker run --rm alpine cat /etc/hosts | |||
</syntaxhighlight> | |||
==Knowledge== | ==Knowledge== | ||
'''disk usage''' | |||
du -h /var | |||
du -sh /var | |||
du -csh ~/Do* | |||
du -csh /var/log /var/lib | |||
du -sh --apparent-size /var/lib | |||
du -h /var/ | sort -rh | head -5 | |||
snap install telegram-sergiusens | snap install telegram-sergiusens | ||
snap install notepad-plus-plus | snap install notepad-plus-plus | ||
snap install skype --classic | snap install skype --classic | ||
sudo apt install gtkhash | |||
apt install net-tools | apt install net-tools | ||
snap install postman | snap install postman | ||
| Line 150: | Line 232: | ||
rm -rf ~/.config/autostart/jetbrains-toolbox.desktop | rm -rf ~/.config/autostart/jetbrains-toolbox.desktop | ||
rm -rf ~/.local/share/JetBrains/Toolbox | rm -rf ~/.local/share/JetBrains/Toolbox | ||
'''reset time zone''' | |||
timedatectl set-ntp true | |||
timedatectl set-ntp false | |||
timedatectl set-time '2021-12-31 23:58:00' | |||
timedatectl set-timezone 'Asia/Kuala_Lumpur' | |||
<syntaxhighlight lang="bash"> | |||
#nano ~/.bashrc | |||
#nano ~/.zshenv | |||
#nano ~/.profile | |||
#nano ~/.bash_profile | |||
export ACADEMIA_WSS="$HOME/chorke/academia" | |||
export ACADEMIA_LOG_PATH="$HOME/.chorke/academia/var/http/logs" | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
source ~/.bashrc | |||
source ~/.profile | |||
source ~/.bash_profile | |||
source ~/.zshenv | |||
source ~/.zprofile/.zlogin | |||
</syntaxhighlight> | |||
'''git stashing''' | |||
git stash; git checkout -b new_branch; git stash pop | |||
git add .; git commit -m "new feature added"; git push | |||
<syntaxhighlight lang="bash"> | |||
ssh-keygen -p -f ~/.ssh/git_academia_chorke_org_rsa | |||
: <<'END_COMMENT' | |||
Enter old passphrase: | |||
Key has comment 'email.id@academia.chorke.org' | |||
Enter new passphrase (empty for no passphrase): | |||
Enter same passphrase again: | |||
Your identification has been saved with the new passphrase. | |||
END_COMMENT | |||
</syntaxhighlight> | |||
===Postgres SSH Dump=== | |||
<syntaxhighlight lang="bash"> | |||
sudo su | |||
mkdir /var/lib/postgresql/.ssh | |||
cp /home/pi/.ssh/cid_academia_rsa* /var/lib/postgresql/.ssh/ | |||
cp /home/pi/.ssh/config /var/lib/postgresql/.ssh/ | |||
cp -r /home/pi/chorke /var/lib/postgresql/ | |||
chown postgres:postgres -R /var/lib/postgresql/.ssh | |||
chown postgres:postgres -R /var/lib/postgresql/chorke | |||
su - postgres | |||
cd ~/chorke/academia/assets | |||
sh copy_dbs_staging2staging_ebis.sh | |||
</syntaxhighlight> | |||
'''comment and uncomment sql''' | |||
sed -i -e 's|^|-- |g' src/main/resources/db/migration/*.sql | |||
sed -i -e 's|^-- ||g' src/main/resources/db/migration/*.sql | |||
==References== | ==References== | ||
{| | |||
| valign="top" | | |||
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04 Install and Use PostgreSQL on Ubuntu 18.04] | * [https://www.digitalocean.com/community/tutorials/how-to-install-and-use-postgresql-on-ubuntu-18-04 Install and Use PostgreSQL on Ubuntu 18.04] | ||
* [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04 Install and Secure Redis on Ubuntu 18.04] | * [https://www.digitalocean.com/community/tutorials/how-to-install-and-secure-redis-on-ubuntu-18-04 Install and Secure Redis on Ubuntu 18.04] | ||
* [https://www.linuxbabe.com/desktop-linux/install-telegram-ubuntu Install Telegram Messenger on Ubuntu] | * [https://www.linuxbabe.com/desktop-linux/install-telegram-ubuntu Install Telegram Messenger on Ubuntu] | ||
* [https://www.sublimetext.com/docs/3/linux_repositories.html#apt Sublime Text Linux Package Manager] | |||
* [https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04 Install Java with Apt on Ubuntu 18.04] | * [https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-on-ubuntu-18-04 Install Java with Apt on Ubuntu 18.04] | ||
* [https:// | * [[Install pgAdmin 4 in Server Mode]] | ||
* [https://askubuntu.com/questions/1178625/ Install PostgreSQL 13 in Ubuntu] | |||
* [https://gist.github.com/invinciblycool/ecc1c6e32b581b68932ac7452f4c911c Installing Postman on Ubuntu] | * [https://gist.github.com/invinciblycool/ecc1c6e32b581b68932ac7452f4c911c Installing Postman on Ubuntu] | ||
* [https://www.pgadmin.org/download/pgadmin-4-apt/ Install PgAdmin4 desktop] | * [https://www.pgadmin.org/download/pgadmin-4-apt/ Install PgAdmin4 desktop] | ||
* [[PostgreSQL]] | * [[PostgreSQL]] | ||
| valign="top" | | |||
* [https://stackoverflow.com/questions/2099471/ Add a prefix beginning of each line] | |||
* [https://www.postgresql.org/download/linux/ubuntu/ PostgreSQL Apt Repository] | |||
* [https://github.com/balena-io/etcher Install Balena Etcher] | |||
* [[LAMP Stack for PI]] | |||
* [[LAPP Stack for PI]] | |||
|} | |||
Latest revision as of 16:42, 22 November 2025
Java
apt install openjdk-8-jdk-headless apt install nodejs apt install maven apt install npm apt install ant
PostgreSQL
Install
apt install postgresql postgresql-contrib sudo su; su - postgres createuser postgres; createdb postgres createuser root; createdb root createuser pi; createdb pi exit; exit
Schema
-- sudo su; su - postgres; psql
CREATE DATABASE academia;
CREATE USER academia WITH ENCRYPTED PASSWORD 'academia';
GRANT ALL PRIVILEGES ON DATABASE academia TO academia;
sudo su; su - postgres psql academia < academia.sql psql -h db00.chorke.org -p 5432 -d academia -U academia psql -h db00.chorke.org -p 5432 -d academia -U academia -W -f academia.sql pg_restore -h db00.chorke.org -p 5432 -d academia -U academia academia.dump
Delete
-- sudo su; su - postgres; psql
REVOKE CONNECT ON DATABASE academia FROM public;
SELECT pg_terminate_backend(pg_stat_activity.pid)
FROM pg_stat_activity
WHERE pg_stat_activity.datname in ('academia');
sudo su; su - postgres ps -ef | grep postgres kill -9 PID
-- sudo su; su - postgres; psql
DROP DATABASE IF EXISTS academia;
PgAdmin4
apt install curl
curl https://www.pgadmin.org/static/packages_pgadmin_org.pub | sudo apt-key add
sudo sh -c 'echo "deb https://ftp.postgresql.org/pub/pgadmin/pgadmin4/apt/$(lsb_release -cs) pgadmin4 main" > \
/etc/apt/sources.list.d/pgadmin4.list && apt update'
apt install pgadmin4-desktop
Redis
apt install redis-server
nano /etc/redis/redis.conf
: <<'END_COMMENT'
# If you run Redis from upstart or systemd, Redis can interact with your
# supervision tree. Options:
# supervised no - no supervision interaction
# supervised upstart - signal upstart by putting Redis into SIGSTOP mode
# supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
# supervised auto - detect upstart or systemd method based on
# UPSTART_JOB or NOTIFY_SOCKET environment variables
# Note: these supervision methods only signal "process is ready."
# They do not enable continuous liveness pings back to your supervisor.
supervised systemd
END_COMMENT
systemctl status redis-server
Workspace
mkdir -p $HOME/chorke
mkdir -p /opt/dev/$USER/chorke/academia
chown $USER:$USER -R /opt/dev/$USER
export ACADEMIA_WSS="$HOME/chorke/academia"
ln -s /opt/dev/$USER/chorke/academia $ACADEMIA_WSS
ls -lah $HOME/chorke
nano ~/.bashrc
Editor
sudo apt install apt-transport-https
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt update;sudo apt install sublime-text
sudo snap install notepad-plus-plus
Git SCM
ssh-keygen -t rsa -b 4096 -C "email.id@academia.chorke.org"
: <<'END_COMMENT'
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): /home/user/.ssh/git_academia_chorke_org_rsa
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user/.ssh/git_academia_chorke_org_rsa
Your public key has been saved in /home/user/.ssh/git_academia_chorke_org_rsa.pub
The key fingerprint is:
SHA256:TXBbBINcPcVtdVFRjs/P+jaxMFAIwr3uqdlt8tmrLVQ email.id@academia.chorke.org
The key's randomart image is:
+---[RSA 4096]----+
| .oo+*++o.+@|
| .++ =o..o+|
| + .....|
| + . E o |
| S . o o|
| . . o o.|
| . o o =|
| o+.o+ +.|
| o..+=o+ooo|
+----[SHA256]-----+
END_COMMENT
ls -lah ~/.ssh/
cat < ~/.ssh/git_academia_chorke_org_rsa.pub
nano ~/.ssh/config
: <<'END_COMMENT'
Host git.academia.chorke.org
HostName git.academia.chorke.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_academia_chorke_org_rsa
User git
END_COMMENT
git config --global user.email "email.id@academia.chorke.org"
git config --global user.name "FULL NAME"
ssh -vT git.academia.chorke.org
Docker
cat <<'EXE' | sudo bash
apt-get update
apt-get install -y ca-certificates curl
install -m 0755 -d /etc/apt/keyrings
apt-get clean
curl -fsSL https://download.docker.com/linux/debian/gpg| sudo tee /etc/apt/keyrings/docker.asc >/dev/null
chmod a+r /etc/apt/keyrings/docker.asc
DISTRIBUTION=$(. /etc/os-release && echo "${VERSION_CODENAME}")
cat << SRC | sudo tee /etc/apt/sources.list.d/docker.sources >/dev/null
Types: deb
Suites: ${DISTRIBUTION}
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
URIs: https://download.docker.com/linux/debian
SRC
apt-get update
apt-get remove -y $(dpkg --get-selections docker.io docker-compose docker-doc podman-docker containerd runc | cut -f1)
apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
apt-get clean
systemctl enabled --start docker
systemctl status docker
systemctl start docker
EXE
cat << EXE | sudo bash
usermod -aG docker ${USER}
echo 'id -nG'|sudo -i -u ${USER} bash
echo 'docker ps -a'|sudo -i -u ${USER} bash
EXE
yq -o=json <<'YML'| \
sudo tee /etc/docker/daemon.json >/dev/null
---
bip: 10.20.13.1/24
mtu: 1500
dns:
- 1.1.1.1
- 8.8.8.8
debug: true
YML
cat <<'EXE' | sudo bash
systemctl stop docker.socket
systemctl stop docker.service
systemctl start docker.service
EXE
su - ${USER}
docker run --rm alpine cat /etc/resolv.conf
docker run --rm alpine cat /etc/hosts
Knowledge
disk usage du -h /var du -sh /var du -csh ~/Do* du -csh /var/log /var/lib du -sh --apparent-size /var/lib du -h /var/ | sort -rh | head -5
snap install telegram-sergiusens snap install notepad-plus-plus snap install skype --classic sudo apt install gtkhash apt install net-tools snap install postman ls -lah ~/.local/share/applications/ ls -lah ~/.config/autostart/ ls -lah ~/.local/share/ rm -rf ~/.local/share/applications/jetbrains-toolbox.desktop rm -rf ~/.config/autostart/jetbrains-toolbox.desktop rm -rf ~/.local/share/JetBrains/Toolbox
reset time zone timedatectl set-ntp true timedatectl set-ntp false timedatectl set-time '2021-12-31 23:58:00' timedatectl set-timezone 'Asia/Kuala_Lumpur'
#nano ~/.bashrc
#nano ~/.zshenv
#nano ~/.profile
#nano ~/.bash_profile
export ACADEMIA_WSS="$HOME/chorke/academia"
export ACADEMIA_LOG_PATH="$HOME/.chorke/academia/var/http/logs"
source ~/.bashrc
source ~/.profile
source ~/.bash_profile
source ~/.zshenv
source ~/.zprofile/.zlogin
git stashing git stash; git checkout -b new_branch; git stash pop git add .; git commit -m "new feature added"; git push
ssh-keygen -p -f ~/.ssh/git_academia_chorke_org_rsa
: <<'END_COMMENT'
Enter old passphrase:
Key has comment 'email.id@academia.chorke.org'
Enter new passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved with the new passphrase.
END_COMMENT
Postgres SSH Dump
sudo su
mkdir /var/lib/postgresql/.ssh
cp /home/pi/.ssh/cid_academia_rsa* /var/lib/postgresql/.ssh/
cp /home/pi/.ssh/config /var/lib/postgresql/.ssh/
cp -r /home/pi/chorke /var/lib/postgresql/
chown postgres:postgres -R /var/lib/postgresql/.ssh
chown postgres:postgres -R /var/lib/postgresql/chorke
su - postgres
cd ~/chorke/academia/assets
sh copy_dbs_staging2staging_ebis.sh
comment and uncomment sql sed -i -e 's|^|-- |g' src/main/resources/db/migration/*.sql sed -i -e 's|^-- ||g' src/main/resources/db/migration/*.sql