diff --git a/README.md b/README.md index 9f90791..1bfd667 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,14 @@ git clone https://github.com/DvvCz/cpkg cargo install --path cpkg ``` +### 🛜 cURL script + +The other options are preferred, but there is an install script. + +```bash +curl -fsSL https://raw.githubusercontent.com/DvvCz/cpkg/master/install.sh | bash +``` + ### 🔄 Upgrading You can easily upgrade your `cpkg` binary using the `cpkg upgrade` command. \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..6bcc54d --- /dev/null +++ b/install.sh @@ -0,0 +1,33 @@ +repo=DvvCz/cpkg +triple=x86_64-unknown-linux-gnu + +if command -v cpkg &> /dev/null; then + echo "Failed to install cpkg -- already exists." + exit 1 +fi + +# Get latest release +release_json=$(curl -s https://api.github.com/repos/$repo/releases/latest) +release_url=$(grep -o "https://.*/cpkg-v.*-$triple" <<< $release_json) +release_filename=$(grep -o "cpkg-v.*" <<< $release_url) + +# CPKG_DIR defaults to ~/.cpkg +cpkg_dir=${CPKG_DIR:=~/.cpkg} + +if ! test -v $cpkg_dir; then + mkdir $cpkg_dir +fi + +if ! test -v $cpkg_dir/bin; then + mkdir $cpkg_dir/bin +fi + +# wget handles folder creation for you +wget -qi - <<< $release_url -O $cpkg_dir/bin/cpkg + +chmod +x $cpkg_dir/bin/cpkg + +echo -e "\nexport CPKG_INSTALL=\"$cpkg_dir\"" >> ~/.bashrc +echo -e 'export PATH=$CPKG_INSTALL/bin:$PATH\n' >> ~/.bashrc + +echo "Installed cpkg to $cpkg_dir and to PATH in ~/.bashrc.\nYou may need to run source ~/.bashrc." \ No newline at end of file