mirror of
https://github.com/nadrad/h-m-m.git
synced 2024-06-21 05:54:59 +02:00
Merge branch 'nadrad:main' into main
This commit is contained in:
commit
70912433c2
89
install.sh
Normal file
89
install.sh
Normal file
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
|
||||
HMM_PATH="$(dirname $0)/h-m-m"
|
||||
MINIMUM_REQUIREMENTS="MINIMUM REQUIREMENTS: PHP 7+ and one of these three must exist on PATH: xclip, xsel or wl-clipboard\n"
|
||||
DESTINATION_DIR="/usr/local/bin"
|
||||
|
||||
# Test if /usr/local/bin exists. If not fallback to /usr/bin
|
||||
if [ ! -d "$DESTINATION_DIR" ]; then
|
||||
DESTINATION_DIR="/usr/bin"
|
||||
fi
|
||||
|
||||
# If h-m-m doesn't exist in the same directory as this script, tries to download from github repository
|
||||
if [ ! -f "$HMM_PATH" ]; then
|
||||
|
||||
if [[ $(curl --write-out '%{http_code}' --silent https://raw.githubusercontent.com/nadrad/h-m-m/main/h-m-m --output /dev/null) == 200 ]]; then
|
||||
curl --silent https://raw.githubusercontent.com/nadrad/h-m-m/main/h-m-m --output /tmp/h-m-m
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "ERROR: Could not download h-m-m\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HMM_PATH="/tmp/h-m-m"
|
||||
else
|
||||
echo -e "ERROR: Online repository not available or Internet is down\n"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "\n> Installer for h-m-m\n"
|
||||
|
||||
# Test if php is on PATH
|
||||
if ! command -v php &> /dev/null ;then
|
||||
echo -e "ERROR: php executable not found on PATH. Installation cancelled.\n";
|
||||
echo -e $MINIMUM_REQUIREMENTS
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test if xclip, xsel or wl-clipboard are on PATH
|
||||
if ! command -v xclip &> /dev/null && ! command -v xsel &> /dev/null && ! command -v wl-clipboard &> /dev/null ;then
|
||||
echo -e "ERROR: xclip, xsel or wl-clipboard must exist on PATH. Installation cancelled.\n";
|
||||
echo -e $MINIMUM_REQUIREMENTS
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Ask for user confirmation to install the script
|
||||
echo -e "This script will install h-m-m on $DESTINATION_DIR and make it executable.\n"
|
||||
echo -e "Proceed (y/N)?"
|
||||
|
||||
read a </dev/tty
|
||||
|
||||
if [[ ! "$a" =~ ^(y|Y) ]] ;then
|
||||
echo -e "Installation cancelled."
|
||||
exit 125
|
||||
fi
|
||||
|
||||
# Ask for user confirmation to overwrite if the script is already installed
|
||||
if test -f "$DESTINATION_DIR/h-m-m"; then
|
||||
echo -e "The file $DESTINATION_DIR/h-m-m already exist.\n"
|
||||
echo -e "Overwrite (y/N)?"
|
||||
|
||||
read a </dev/tty
|
||||
|
||||
if [[ ! "$a" =~ ^(y|Y) ]] ;then
|
||||
echo -e "Installation cancelled."
|
||||
exit 125
|
||||
fi
|
||||
fi
|
||||
|
||||
# Copy the script
|
||||
sudo cp $HMM_PATH $DESTINATION_DIR/h-m-m
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "ERROR: Could not copy h-m-m to $DESTINATION_DIR\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Delete temporary file, if exists.
|
||||
rm -f /tmp/h-m-m
|
||||
|
||||
# Make the copied file executable
|
||||
sudo chmod +x $DESTINATION_DIR/h-m-m
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "ERROR: Could not make the script $DESTINATION_DIR/h-m-m executable.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\nSUCCESS! h-m-m installed.\n"
|
25
readme.md
25
readme.md
|
@ -110,22 +110,37 @@ Most mind mapping applications use a similar format for copying and pasting. As
|
|||
|
||||
# Installing
|
||||
|
||||
**h-m-m** is a single php file. You can download it from here, or clone it on your computer using git and add a scheduled job to update it once a week.
|
||||
|
||||
## 1. Manual installation (Linux, Windows, and Mac)
|
||||
|
||||
**h-m-m** is a single php file. You can download it from here, or clone it on your computer using git and add a scheduled job to update it once a day or week.
|
||||
|
||||
You also need to have the following installed for h-m-m to work:
|
||||
|
||||
* php
|
||||
* either php 8, or
|
||||
* older versions of php along with the `mbstring` package (e.g., `php7.2-mbstring`)
|
||||
* `xclip`, `xsel`, or `wl-clipboard` in Linux. (Windows and Mac don't need it)
|
||||
|
||||
After downloading or cloning, you can run `php h-m-m` in your terminal to run the program with a blank map or `php h-m-m filename` to open an existing file. If you don't already have a php interpreter installed, you would need to install it as well. Note: You don't need to set up a "web server" to run it because it's not a web application, but rather a terminal application that works like those written in Python, Bash, etc.
|
||||
|
||||
Optionally, you can make the file executable by running the `chmod +x h-m-m` in your terminal, and afterward, you can run it as `h-m-m filename` (assuming that **h-m-m** is in your path).
|
||||
|
||||
In Linux, you need to have `xclip`, `xsel`, or `wl-clipboard` installed as well.
|
||||
|
||||
## 2. Installation for Arch Linux
|
||||
|
||||
In Arch Linux, you can use the `h-m-m-git` AUR package to install it.
|
||||
|
||||
|
||||
# Troubleshooting
|
||||
## 3. Installation script for Linux
|
||||
|
||||
If it doesn't work, you probably need to install `php7.2-mbstring` (e.g., `sudo apt install php7.2-mbstring` in Ubuntu). Replace `7.2` with the version of php installed on your system. Just in case, you can find the version number by running `php -v`.
|
||||
You can run the following command to install h-m-m:
|
||||
|
||||
In general, upgrading to a newer version of php would help as well; at least 7.4.
|
||||
wget -q -O - 'https://raw.githubusercontent.com/nadrad/h-m-m/main/install.sh' | bash
|
||||
|
||||
This command downloads and runs the install.sh script, which it turn downloads h-m-m, copies it to `/usr/local/bin`, checks the dependencies, and makes it executable.
|
||||
|
||||
After installing, you can run `h-m-m` from anywhere in your terminal to run the application with an empty map, or `h-m-m filename` to open an existing file.
|
||||
|
||||
|
||||
# Compatibility
|
||||
|
|
Loading…
Reference in a new issue