-
-
Save martinhbramwell/347d8fd4b3f073b099aabbf4512c14b4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash | |
# | |
export MYPWD=""; # MySQL password | |
export ADMPWD=""; # Administrator password | |
export THESITE="my site"; # Site name | |
export USERCTX=".profile"; | |
source ${HOME}/${USERCTX}; | |
if [ "${BASH_SOURCE[0]}" -ef "$0" ] | |
then | |
echo -e " | |
- o 0 o - | |
This first section is set up to facilitate snippet drag and drop from the GitHub gist. | |
At the end of it you'll be ready to get the files and run them. | |
- o 0 o - | |
Steps from a completely raw install | |
................................... | |
1. Addressing | |
# Install net-tools | |
sudo apt install net-tools | |
# Find out your IP address | |
ifconfig | |
# You will have gotten something like this: | |
# ens3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 | |
# inet 192.168.122.98 netmask 255.255.255.0 broadcast 192.168.122.255 | |
# : : : : : : : : : : : | |
# : : : : : : : : : : : | |
# | |
# So, your new server's address is 192.168.122.98 | |
2. At your workstation make preparations to connect to the new server through an SSH client. Copy your SSH public key. | |
3. SSH server stuff... (on the new server). | |
# Create directory and keys file | |
mkdir -p ${HOME}/.ssh; | |
# Paste public key of workstation after entering: | |
cat > ${HOME}/.ssh/authorized_keys | |
** paste the text of your id_rsa.pub file here the hit '<ctrl>-d' to save and exit | |
<ctrl>-d is used to exit | |
# Fix permissions | |
chmod u+x,go-rwx ${HOME}/.ssh; | |
chmod go-wx ${HOME}/.ssh/authorized_keys; | |
3. APT house cleaning | |
echo -e "\n ********* Updating ********* \n\n"; | |
sudo apt -y update; | |
echo -e "\n ********* Upgrading ********* \n\n"; | |
sudo DEBIAN_FRONTEND=noninteractive apt -y upgrade; | |
echo -e "\n ********* Dist Upgrading ********* \n\n"; | |
sudo apt -y dist-upgrade; | |
echo -e "\n ********* Cleaning ********* \n\n"; | |
sudo apt -y clean; | |
echo -e "\n ********* Removing ********* \n\n"; | |
sudo apt -y autoremove; | |
# ####################################################################################################################### | |
"; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "\nQuitting"; | |
exit; | |
fi; | |
echo -e " | |
# ####################################################################################################################### | |
*** DANGER *** | |
This is a tool that I use. It MIGHT work for you. I offer no guarantees of any kind. | |
Personally I would NEVER use these scripts on any machine containing anything I would not want to lose. | |
*** PURPOSE *** | |
These scripts prepare ERPNext on either Ubuntu Focal (20.04 LTS) or Bionic (18.04 LTS) on a virtual machine under QEMU/KVM. | |
They might work on earlier versions or other environments. I have not tried. | |
*** USAGE *** | |
Steps: | |
1. Create a new user for working with ERPNext, give it 'sudoer' privileges | |
# Create user | |
sudo adduser erpdev; | |
# Add to sudoers | |
sudo usermod -aG sudo erpdev; | |
# Create SSH directory for new user | |
sudo mkdir /home/erpdev/.ssh; | |
# Place pub keys of workstations | |
cat > authorized_keys | |
** paste the text of your id_rsa.pub file here the hit '<ctrl>-d' to save and exit | |
<ctrl>-d | |
# Move authorized keys file to new user's home | |
sudo mv authorized_keys /home/erpdev/.ssh | |
# Fix permissions | |
sudo chmod go-rwx /home/erpdev/.ssh; | |
sudo chmod -R o-rwx /home/erpdev/.ssh; | |
# sudo chmod g-rwx /home/erpdev/.ssh/id_rsa; | |
sudo chown -R erpdev:erpdev /home/erpdev/.ssh; | |
2. *** Logout as yourself. Log back in as user 'erpdev'. *** | |
3. Set up SUDO_ASKPASS. (The scripts depend on it) | |
# Ensure you have a directory '${HOME}/.ssh' | |
mkdir -p ${HOME}/.ssh; | |
# Create a file '${HOME}/.ssh/.supwd.sh' containing the following two lines, eg: cat > ${HOME}/.ssh/.supwd.sh | |
#!/usr/bin/env bash | |
echo ' <your user's password goes here> '; | |
# Run this command: | |
chmod +x ${HOME}/.ssh/.supwd.sh; | |
# Append the following line to your ${HOME}/.profile file, eg: cat >> ${HOME}/.profile | |
export SUDO_ASKPASS=${HOME}/.ssh/.supwd.sh; | |
# 'source' your ${HOME}/.profile file, to make the SUDO_ASKPASS immediately useful. | |
source ${HOME}/.profile; | |
# This command should display your password | |
${HOME}/.ssh/.supwd.sh; | |
# This command should ALSO display your password | |
${SUDO_ASKPASS}; | |
4. Get the first of the installer script files ready to run | |
# Move into a temporary directory | |
mkdir -p /tmp/erpnext | |
chmod ugo+rwx /tmp/erpnext | |
cd /tmp/erpnext | |
# Pull and set permissions for the first of the four files (this one) | |
wget -O ErpNextQikInstall_0.sh gist.githubusercontent.com/martinhbramwell/347d8fd4b3f073b099aabbf4512c14b4/raw/ErpNextQikInstall_0.sh?cachebust=anything; | |
chmod +x ErpNextQikInstall_0.sh; | |
# Edit the three settings at the top of the script: MYPWD, ADMPWD & THESITE, eg: nano ErpNextQikInstall_0.sh; | |
# nano ErpNextQikInstall_0.sh; # If you use nano, use <ctrl>-x to exit | |
# Execute the script to ensure 'sudo -A' is working | |
./ErpNextQikInstall_0.sh; | |
# *** The steps below test if you have done everything to get it working. *** | |
# ####################################################################################################################### | |
"; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "\nQuitting"; | |
exit; | |
fi; | |
export WARNING_MSG="Warnings:"; | |
export WARNING="${WARNING_MSG}"; | |
export SSHDIR=".ssh"; | |
export SUPWDFILE=".supwd.sh"; | |
export SUPWDPATH="${HOME}/${SSHDIR}/${SUPWDFILE}"; | |
echo -e " | |
Ensuring there is a '${SUPWDFILE}' executable for 'SUDO_ASKPASS'..."; | |
[ -f ${SUPWDPATH} ] || WARNING="${WARNING}\n - ${SUPWDPATH} :: was not found"; | |
chmod u+x,go-rwx ${SUPWDPATH}; | |
export USERCTX=".profile"; | |
export ASKPASS_ENVVAR="export SUDO_ASKPASS=\${HOME}/.ssh/.supwd.sh"; | |
echo -e " | |
Ensuring the 'SUDO_ASKPASS' environment variable will be exported at log in....${ASKPASS_ENVVAR}"; | |
cat ${HOME}/${USERCTX} | grep "${ASKPASS_ENVVAR}" >/dev/null || WARNING="${WARNING}\n - SUDO_ASKPASS :: expected '${HOME}/${USERCTX}' to contain '${ASKPASS_ENVVAR}'."; | |
source ${HOME}/${USERCTX}; | |
echo -e " | |
Ensuring the 'SUDO_ASKPASS' env var has a value"; | |
[ -z "${SUDO_ASKPASS}" ] && WARNING="${WARNING}\n - SUDO_ASKPASS :: expected 'SUDO_ASKPASS' to contain '${SUPWDPATH}'."; | |
echo -e " | |
Ensuring 'sudo -A command' actually works"; | |
sudo -A touch /scrap 2>/dev/null || WARNING="${WARNING}\n - SUDO_ASKPASS :: Failed to run 'sudo -A command'."; | |
sudo -A rm /scrap 2>/dev/null; | |
echo -e " | |
Ensuring ERPNext Administrator password 'ADMPWD' has been set."; | |
[ -z "${ADMPWD}" ] && WARNING="${WARNING}\n - ERPNext Administrator password 'ADMPWD' has no value set."; | |
echo -e " | |
Ensuring MariaDb root password 'MYPWD' has been set."; | |
[ -z "${MYPWD}" ] && WARNING="${WARNING}\n - MariaDb root password 'MYPWD' has no value set."; | |
echo -e " | |
Ensuring the name for your new site 'THESITE' has been set."; | |
[ "my site" = "${THESITE}" ] && WARNING="${WARNING}\n - Name for your new site 'THESITE' has no VALID value set. [ '${THESITE}' ?? ]"; | |
if [[ "${WARNING}" != "${WARNING_MSG}" ]]; then | |
echo -e "\n${WARNING}"; | |
echo -e "\n To run these scripts you will need to understand how to get 'SUDO_ASKPASS' to work."; | |
echo -e " Try https://stackoverflow.com/questions/12608293/how-to-setup-a-sudo-askpass-environment-variable"; | |
echo -e " Note: The preceding tests expect you'll use a file named '${SUPWDPATH}'"; | |
exit 1; | |
else | |
echo -e "\n\nNo issues found"; | |
mkdir -p ${HOME}/.ssh/secrets/ | |
cd ${HOME}/.ssh/secrets/ | |
cat > ${HOME}/.ssh/secrets/pwds.sh <<PWEOF | |
#!/usr/bin/env bash | |
# | |
export MYPWD="${MYPWD}"; # MySQL password | |
export ADMPWD="${ADMPWD}"; # Administrator password | |
export THESITE="${THESITE}"; # Site name | |
PWEOF | |
chmod go-rwx ${HOME}/.ssh/secrets; | |
chmod go-rwx ${HOME}/.ssh/secrets/*.*; | |
fi; | |
echo -e "....................."; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "\nQuitting"; | |
exit; | |
fi; | |
echo -e " | |
# # ####################################################################################################################### | |
4. Get the second of the installer script files ready to run | |
# Pull and set permissions | |
cd /tmp/erpnext; | |
wget -O ErpNextQikInstall_1.sh gist.githubusercontent.com/martinhbramwell/347d8fd4b3f073b099aabbf4512c14b4/raw/ErpNextQikInstall_1.sh?cachebust=anything; | |
chmod +x ErpNextQikInstall_1.sh; | |
# Execute the script | |
./ErpNextQikInstall_1.sh; | |
# *** Notes *** | |
# 1. You'll notice the files are divided into three sections by if ... elif ... else ... fi. | |
# If you get part way through a script and are forced to stop and retry you can move the | |
# successfully executed parts into the 'Skipped' section. | |
# 2. The bits to do with 'sudo -A apt install -y ntpdate;' are to force correct date and time. | |
# I use virtual machines with hot snapshot capability. Reverting a snapshot after hours or days | |
# will find the date and time set to the time the snapshots was taken, which will cause 'apt' to fail. | |
"; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "\nQuitting"; | |
exit; | |
fi; | |
fi |
#!/usr/bin/env bash | |
# | |
if [ $(id -u) = 0 ]; then | |
echo -e "These scripts must not be run as root!"; | |
exit 1; | |
fi; | |
source ${HOME}/.ssh/secrets/pwds.sh; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "Quitting"; | |
exit; | |
elif [ "$key" = 's' ]; then | |
echo -e "Not Skipping"; | |
# #################################################################################################### | |
# #################################################################################################### | |
exit; | |
else | |
# echo -e "\n\nSynchronizing clock"; | |
# date; | |
# sudo -A ntpdate pool.ntp.org; | |
# date; | |
# #################################################################################################### | |
echo -e "\nConfiguring firewall\n\n"; | |
sudo -A ufw default deny incoming; | |
sudo -A ufw allow ssh; | |
sudo -A ufw allow http; | |
sudo -A ufw allow https; | |
sudo -A ufw allow 8000; | |
sudo -A ufw allow 9000; | |
sudo -A ufw allow 11000; | |
sudo -A ufw allow imap; | |
sudo -A ufw allow smtp; | |
sudo -A ufw allow ntp; | |
sudo -A ufw disable; | |
echo -e "\nInstalling clock synchronizer"; | |
sudo -A apt install -y ntpdate; | |
echo -e "\n\nSynchronizing clock"; | |
date; | |
sudo -A ntpdate pool.ntp.org; | |
date; | |
sudo -A apt -y install git; | |
sudo -A apt -y install curl; | |
sudo -A apt -y install tree; | |
echo -e "\n\nPatch SSH config"; | |
sudo -A sed -i '/ChallengeResponseAuthentication/c\ChallengeResponseAuthentication no' /etc/ssh/sshd_config; | |
sudo -A sed -i '/PasswordAuthentication/c\PasswordAuthentication no' /etc/ssh/sshd_config; | |
sudo -A sed -i '/UsePAM/c\UsePAM no' /etc/ssh/sshd_config; | |
sudo -A sed -i '/PermitRootLogin/c\PermitRootLogin no' /etc/ssh/sshd_config; | |
echo -e "Apt preparation"; | |
sudo -A apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8; | |
sudo -A add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mariadb.mirror.liquidtelecom.com/repo/10.4/ubuntu $(lsb_release -cs) main" | |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo -A apt-key add - | |
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo -A tee /etc/apt/sources.list.d/yarn.list | |
sudo -A apt -y update | |
echo -e "Apt Installs"; | |
# sudo -A apt -y install python-minimal; | |
sudo -A apt -y install python3-dev; | |
sudo -A apt -y install python3-setuptools; | |
sudo -A apt -y install python3-pip; | |
sudo -A apt -y install python3-testresources; | |
sudo -A apt -y install nginx; | |
sudo -A apt -y install software-properties-common; | |
sudo -A apt -y install redis-server; | |
sudo -A apt -y install mariadb-server-10.4; | |
sudo -A apt -y install mariadb-client; | |
sudo -A apt -y install libmysqlclient-dev; | |
sudo -A apt -y install yarn; | |
export MYSQL_CNF_FILE="${HOME}/.my.cnf"; | |
# export MYSQL_CNF_FILE="/etc/mysql/mariadb.cnf"; # THIS IS A BETTER FILE TO USE FOR PRODUCTION PURPOSES !!!! | |
sudo -A cat ${MYSQL_CNF_FILE} | |
tee ${MYSQL_CNF_FILE} >/dev/null <<MCF | |
[client] | |
user=root | |
password="${MYPWD}" | |
[mysql] | |
user=root | |
password="${MYPWD}" | |
[mysqldump] | |
user=root | |
password="${MYPWD}" | |
[mysqldiff] | |
user=root | |
password="${MYPWD}" | |
MCF | |
chmod u+x,go-rwx ${MYSQL_CNF_FILE}; | |
# echo -e " | |
# ${MYSQL_CNF_FILE} | |
# ${MYPWD} | |
# ++++++++++++++ | |
# "; | |
if mysql -u root -e "select 1+1;" mysql &>/dev/null; then | |
echo -e "MariaDB already secured"; | |
else | |
echo "Securing MariaDB...."; | |
sudo -A mysql_secure_installation 2>/dev/null <<MSI | |
n | |
y | |
${MYPWD} | |
${MYPWD} | |
y | |
y | |
y | |
y | |
MSI | |
echo -e "Update MySql"; | |
sudo -A mysql -u root -e "FLUSH PRIVILEGES;;" mysql; | |
fi; | |
sudo -A service mysql restart | |
mysql -u root -p${MYPWD} -e "SELECT 1+1"; | |
export MYCNF_PATCH="/dev/shm/mycnf.patch"; | |
sudo -A tee ${MYCNF_PATCH} >/dev/null <<MCFP18 | |
--- my.cnf 2020-05-09 19:27:56.000000000 +0000 | |
+++ my.cnf.new 2020-05-19 22:01:02.759916503 +0000 | |
@@ -28,6 +28,9 @@ | |
nice = 0 | |
[mysqld] | |
+character-set-client-handshake = FALSE | |
+character-set-server = utf8mb4 | |
+collation-server = utf8mb4_unicode_ci | |
# | |
# * Basic Settings | |
# | |
MCFP18 | |
export MYCNFN="my.cnf"; | |
echo -e "Patching '${MYCNFN}'"; | |
pushd /etc/mysql/ >/dev/null; | |
export MYCNF="$(realpath ./${MYCNFN})"; | |
sudo -A patch -p0 --forward ${MYCNF} < ${MYCNF_PATCH} >/dev/null; | |
popd >/dev/null; | |
echo -e "\n\nInstalling NodeJs and NPM"; | |
curl -sL https://deb.nodesource.com/setup_12.x | sudo -A -E bash - | |
sudo -A apt install -y nodejs | |
echo -e "\nInstalled NodeJs and NPM\n\n"; | |
echo -e "\nConfiguring file watchers\n\n"; | |
echo fs.inotify.max_user_watches=524288 | sudo -A tee -a /etc/sysctl.conf && sudo -A sysctl -p | |
echo -e "\n\nInstall bench"; | |
sudo -A pip3 install frappe-bench | |
echo -e " | |
_____________________________________________________ | |
Sanity checks | |
"; | |
echo -e "Check NGinx ok"; | |
sudo -A service nginx status | |
echo -e "\n\nCheck Mysql ok"; | |
# mysql -u root -p${MYPWD} -e "SELECT 1+1"; | |
sudo -A mysql -u root -e "SELECT 1+1"; | |
echo -e "\n\nNodeJs version"; | |
node --version | |
echo -e "NPM version"; | |
npm --version | |
echo -e "\n\nCheck Redis ok (expecting PONG)"; | |
redis-cli ping | |
echo -e " | |
_____________________________________________________ | |
Ready to install Frappe .... | |
"; | |
export PATH="${HOME}/.local/bin:${PATH}"; | |
cd ${HOME} | |
bench --version | |
bench init --frappe-branch version-12 --python /usr/bin/python3 frappe-bench | |
if [[ "$(lsb_release -sr)" < "20.04" ]]; then | |
echo -e " | |
Correcting for 'pandas' bug. | |
"; | |
else | |
echo -e " | |
Correcting for 'pandas' bug. | |
This takes a LONG time. It can appear to hang for 10 - 20 minutes at the line: | |
Building wheel for pandas (setup.py) ... \ | |
"; | |
fi | |
cd ${HOME}/frappe-bench | |
./env/bin/pip install numpy==1.18.5 | |
./env/bin/pip install pandas==0.24.2 | |
sudo -A ufw --force enable; | |
echo -e " | |
Done | |
========================================================================================================================= | |
# # ####################################################################################################################### | |
*** You'll need to *restart* your virtual server before doing the next steps *** | |
*** Then ... | |
5. After restarting your server, run the final two scripts | |
# Pull and set permissions on the third script | |
mkdir -p /tmp/erpnext | |
cd /tmp/erpnext | |
wget -O ErpNextQikInstall_2.sh gist.githubusercontent.com/martinhbramwell/347d8fd4b3f073b099aabbf4512c14b4/raw/ErpNextQikInstall_2.sh?cachebust=anything; | |
chmod +x ErpNextQikInstall_2.sh; | |
# Pull and set permissions on the fourth script | |
mkdir -p /tmp/erpnext | |
cd /tmp/erpnext | |
wget -O ErpNextQikInstall_3.sh gist.githubusercontent.com/martinhbramwell/347d8fd4b3f073b099aabbf4512c14b4/raw/ErpNextQikInstall_3.sh?cachebust=anything; | |
chmod +x ErpNextQikInstall_3.sh; | |
# In one terminal session --> execute the third script | |
cd /tmp/erpnext | |
./ErpNextQikInstall_2.sh; | |
*** The last part of the third script leaves ErpNext running and waiting for connections! *** | |
*** It is normal for it to *appear* to hang at the end after displaying the following lines: *** | |
: : : : : : : | |
: : : : : : : | |
15:18:23 watch.1 | Rebuilding modules.min.js | |
15:18:24 watch.1 | Rebuilding barcode_scanner.min.js | |
15:18:26 watch.1 | Rebuilding data_import_tools.min.js | |
# When the third script is complete and waiting, open a new terminal window and execute the fourth script | |
cd /tmp/erpnext | |
./ErpNextQikInstall_3.sh; | |
"; | |
exit; | |
# #################################################################################################### | |
fi | |
echo -e " | |
Done | |
========================================== | |
"; | |
exit; | |
#!/usr/bin/env bash | |
# | |
source ${HOME}/.ssh/secrets/pwds.sh; | |
echo -e " | |
*** Attention *** | |
This script produces a lot of output, then appears to slow down and come to a stop at... | |
: : : : : : : | |
15:18:23 watch.1 | Rebuilding social.min.js | |
15:18:23 watch.1 | Rebuilding modules.min.js | |
15:18:24 watch.1 | Rebuilding barcode_scanner.min.js | |
15:18:26 watch.1 | Rebuilding data_import_tools.min.js | |
It does not stop because it failed. | |
You will be seeing the Frappe application server running and ready to accept connections. | |
*** IT MUST BE RUNNING IN ORDER TO INSTALL ERPNext (script #3) *** | |
While installing ERPNext it will display many log lines as it reports the progress of the installation. | |
"; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "Quitting"; | |
exit; | |
elif [ "$key" = 's' ]; then | |
echo -e "Skipping"; | |
# #################################################################################################### | |
# #################################################################################################### | |
exit; | |
else | |
echo -e "\nCalibrating date & time..."; | |
sudo -A ntpdate pool.ntp.org; | |
# #################################################################################################### | |
cd ${HOME}/frappe-bench/ | |
./env/bin/pip3 install -e apps/frappe/ | |
bench start | |
# #################################################################################################### | |
fi | |
echo -e " | |
Done | |
========================================== | |
"; | |
exit; |
#!/usr/bin/env bash | |
# | |
source ${HOME}/.ssh/secrets/pwds.sh; | |
echo -e " | |
*** Notice *** | |
#1 | |
*** THE 'bench' MUST BE RUNNING IN ORDER TO COMPLETE THIS SCRIPT *** | |
You should either: | |
- Check that Script #2 is still running OR | |
- Start the 'bench' in a separate terminal window | |
While installing ERPNext it will display many log lines as it reports the progress of the installation. | |
#2 The 'bench' will terminate part way through this script. You will be asked to | |
start it again before continuing with the last two tasks. | |
"; | |
read -n1 -r -p "Press <q> to quit, any other to proceed..." key | |
if [ "$key" = 'q' ]; then | |
echo -e "Quitting"; | |
exit; | |
elif [ "$key" = 's' ]; then | |
echo -e "Skipping"; | |
# #################################################################################################### | |
# #################################################################################################### | |
exit; | |
else | |
echo -e "\nCalibrating date & time..."; | |
sudo -A ntpdate pool.ntp.org; | |
# #################################################################################################### | |
echo -e "Adding '${THESITE}' to /etc/hosts"; | |
grep "127.0.0.1 *${THESITE}" /etc/hosts >/dev/null || \ | |
echo -e "\n127.0.0.1 ${THESITE}" | sudo -A tee -a /etc/hosts; | |
cat /etc/hosts; | |
pushd ${HOME}/frappe-bench/; | |
export NEW_SITE="${THESITE}"; | |
mkdir -p ./config; | |
touch ./config/nginx.conf; | |
mv ./config/nginx.conf ./config/nginx.conf_$(date +"%Y%m%d_%H%M"); | |
echo -e "Creating the new '${NEW_SITE}' site in Frappe"; | |
bench new-site --mariadb-root-password ${MYPWD} --admin-password ${ADMPWD} ${NEW_SITE} | |
echo -e "Configuring NGinx for the '${NEW_SITE}' site."; | |
bench config dns_multitenant on | |
echo "" > sites/currentsite.txt | |
bench setup nginx | |
echo -e "Linking Frappe site config to NGinx site config."; | |
pushd /etc/nginx/sites-enabled/ | |
sudo -A rm default | |
sudo -A ln -s /home/erpdev/frappe-bench/config/nginx.conf nginx.conf | |
popd | |
popd | |
ls -la /etc/nginx/sites-enabled/ | |
echo -e "Restarting NGinx."; | |
sudo -A service nginx restart | |
echo -e "Adding '${NEW_SITE}' to /etc/hosts"; | |
grep "127.0.0.1 *${NEW_SITE}" /etc/hosts >/dev/null || \ | |
echo -e "\n127.0.0.1 ${NEW_SITE}" | sudo -A tee -a /etc/hosts; cat /etc/hosts; | |
pushd ${HOME}/frappe-bench/; | |
bench get-app --branch version-12 erpnext | |
echo -e "Building ERPNext app "; | |
./env/bin/pip3 install -e apps/erpnext/ | |
echo -e "Installing ERPNext app in '${NEW_SITE}' site"; | |
bench --site ${NEW_SITE} install-app erpnext | |
popd | |
echo -e " | |
The last two tasks will fail if the 'bench' is not running | |
Check back to the other console to restart bench if it failed, executing ... | |
cd \${HOME}/frappe-bench | |
bench start | |
... when bench has finished starting."; | |
read -n1 -r -p "...press any key to proceed (or q to quit)..." key | |
if [ "$key" != 'q' ]; then | |
echo -e " | |
Continuing..."; | |
pushd ${HOME}/frappe-bench >/dev/null; | |
echo -e "\nClearing cache..."; | |
bench --site ${THESITE} clear-cache; | |
echo -e "\nMigrating changes ..."; | |
bench --site ${THESITE} migrate | |
popd >/dev/null; | |
else | |
echo -e " | |
Skipped 'clear-cache' and 'migrate' ..."; | |
fi; | |
# #################################################################################################### | |
fi | |
echo -e " | |
Done | |
========================================== | |
"; | |
exit; |
Yes you are correct about those things.
If you have suggested patches or can test in other environments I'd be glad to know.
Was working on that stuff yesterday in 20.04, instead of 18.04, to see if it was going to be possible at all, but I now have other things demanding my attentions. Sorry.
Hi again.
I have revised those scripts and posted about them in the discussion group:
https://discuss.erpnext.com/t/an-alternative-installer-for-ubuntu-20-04-lts/61533?u=martinhbramwell
i love your work. it saves time
In a fresh 20.04 there is no curl.
you should include
sudo -A apt -y install curl;
in
ErpNextQikInstall_1.sh
Thank you for your efforts!
Fixed!
Thanks!
It was actually being installed about 10 lines below the first call to use it. It gets really tiresome to always go all the way back to square one to check every minor change, like playing Snakes and Ladders where there are no ladders. :-(
Apart from that ... does it woek for you 100% error free? in 18.04? in 20.04?
Yes and no.
In the end it not creating the new site.
In sites directory there is no sitename
Now I will try with your new one.
Hmmm. You are editing the three variables at the beginning of the first script?
#!/usr/bin/env bash
#
export MYPWD=""; # MySQL password
export ADMPWD=""; # Administrator password
export THESITE="my site"; # Site name
I don't mind multiple scripts. If they cost me a few extra minutes, its still nothing compared to the time I'd spend solving the issues that make it necessary to split them up. If it is that important to you and if you can determine:
- How to avoid rebooting after the 2nd script.
- Why something in the last script crashes the "bench", which is started in the 3rd script
... then I will be happy to take the time to stitch them all together.
Both are issues within Frappe/ERPNext and it is the responsibility of those developers to provide official scripts that actually work.
Hi martinhbramwell,
I'am try install ERPNext in Ubuntu 20.04 , Which file do I need to download over 5 of your files?
The idea is that you drag and drop lines from the first file, editing as needed, until you reach the lines that download the first file.
You edit three details at the top of that page, then execute it. When complete it will inform you that everything is properly set up for continuing with the subsequent files. You can then cut and paste the download commands for those files too.
You should not need to much more than a few passwords.
I have published a video that shows the whole process with a few minor additions.
This worked like charm. Thank you @martinhbramwell
Really? I'm amazed! So much has changed in Frappe & ERPNext ..........
certain deps such as git and curl are not present on lxc ubuntu. perhaps install those too during script 1?
also script 3 gives:
Using cached Werkzeug-0.16.0-py2.py3-none-any.whl (327 kB)
ERROR: frappe 12.5.1 has requirement Werkzeug==0.16.1, but you'll have werkzeug 0.16.0 which is incompatible.
Installing collected packages: werkzeug
Attempting uninstall: werkzeug
Found existing installation: Werkzeug 0.16.1
Uninstalling Werkzeug-0.16.1:
Successfully uninstalled Werkzeug-0.16.1
Successfully installed werkzeug-0.16.0