mirror of
https://github.com/YunoHost-Apps/squid3_ynh.git
synced 2024-09-03 20:26:11 +02:00
Updated app to latest example_ynh
This commit is contained in:
parent
75747ab391
commit
070f201f0d
10 changed files with 375 additions and 123 deletions
18
README.md
18
README.md
|
@ -1,8 +1,7 @@
|
||||||
# Squid3 Proxy for Yunohost with LDAP
|
# Squid3 Proxy for Yunohost with LDAP
|
||||||
|
|
||||||
[](https://ci-apps.yunohost.org/jenkins/job/squid3%20%28Community%29/lastBuild/consoleFull)
|
[](https://dash.yunohost.org/appci/app/squid3)  
|
||||||
[](https://install-app.yunohost.org/?app=peertube)<br><br>
|
[](https://install-app.yunohost.org/?app=squid3)
|
||||||
=======
|
|
||||||
|
|
||||||
## Interesting links
|
## Interesting links
|
||||||
|
|
||||||
|
@ -15,12 +14,10 @@ Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It r
|
||||||
|
|
||||||
## Instruction
|
## Instruction
|
||||||
|
|
||||||
1. The app will not ask anything while installation.
|
|
||||||
1. There is **no update** script.
|
|
||||||
1. The app can not be **multi-instance**(can't be installed many times on same server).
|
1. The app can not be **multi-instance**(can't be installed many times on same server).
|
||||||
1. **LDAP** is there(Registered users can use there login username and password to browse internet through the proxy)
|
2. **LDAP** is there(Registered users can use there login username and password to browser internet through the proxy)
|
||||||
1. **Port number** to be used will be sent to the **admin mail** of the Yunohost server.
|
3. **Port number** used by the proxy will be sent to the **admin mail** of the Yunohost server.
|
||||||
1. The username and password is **asked twice** first time you start the browser(I have no idea why this happens).
|
4. The username and password is **asked twice** first time you start the browser(I have no idea why this happens).
|
||||||
|
|
||||||
## Configure Squid3 for Firefox
|
## Configure Squid3 for Firefox
|
||||||
|
|
||||||
|
@ -35,3 +32,8 @@ Squid is a caching proxy for the Web supporting HTTP, HTTPS, FTP, and more. It r
|
||||||
|
|
||||||
## Special Thanks
|
## Special Thanks
|
||||||
Thanks to **Fred** to write the instruction to configure Squid for Yunohost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/
|
Thanks to **Fred** to write the instruction to configure Squid for Yunohost. French: https://memo-linux.com/installer-squid3-sur-un-serveur-yunohost/
|
||||||
|
|
||||||
|
#### Supported architectures
|
||||||
|
|
||||||
|
* x86-64 - [](https://ci-apps.yunohost.org/ci/apps/squid3/)
|
||||||
|
* ARMv8-A - [](https://ci-apps-arm.yunohost.org/ci/apps/squid3/)
|
||||||
|
|
|
@ -13,25 +13,17 @@
|
||||||
setup_nourl=0
|
setup_nourl=0
|
||||||
setup_private=0
|
setup_private=0
|
||||||
setup_public=0
|
setup_public=0
|
||||||
upgrade=0
|
upgrade=1
|
||||||
|
#upgrade=1 from_commit=CommitHash
|
||||||
backup_restore=1
|
backup_restore=1
|
||||||
multi_instance=0
|
multi_instance=0
|
||||||
incorrect_path=0
|
# This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version.
|
||||||
|
# incorrect_path=1
|
||||||
port_already_use=1
|
port_already_use=1
|
||||||
change_url=0
|
change_url=0
|
||||||
;;; Levels
|
;;; Levels
|
||||||
Level 1=auto
|
# If the level 5 (Package linter) is forced to 1. Please add justifications here.
|
||||||
Level 2=auto
|
|
||||||
Level 3=auto
|
|
||||||
# Level 4: If the app supports LDAP and SSOwat, turn level 4 to '1' and add a link to an issue or a part of your code to show it.
|
|
||||||
# If the app does not use LDAP nor SSOwat, and can't use them, turn level 4 to 'na' and explain as well.
|
|
||||||
Level 4=na
|
|
||||||
Level 5=auto
|
Level 5=auto
|
||||||
Level 6=auto
|
|
||||||
Level 7=auto
|
|
||||||
Level 8=0
|
|
||||||
Level 9=0
|
|
||||||
Level 10=0
|
|
||||||
;;; Options
|
;;; Options
|
||||||
Email=anmol@datamol.org
|
Email=anmol@datamol.org
|
||||||
Notification=yes
|
Notification=yes
|
||||||
|
|
55
issue_template.md
Normal file
55
issue_template.md
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**How to post a meaningful bug report**
|
||||||
|
1. *Read this whole template first.*
|
||||||
|
2. *Make sure you are on the right place:*
|
||||||
|
- *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change url...), you are on the right place!*
|
||||||
|
- *Otherwise, the issue may be due to the app itself. Refer to its documentation or repository for help.*
|
||||||
|
- *In doubt, ask here and we will figure it out together.*
|
||||||
|
3. *Delete these italic comments as you write over them below, and remove this guide.*
|
||||||
|
---
|
||||||
|
|
||||||
|
### Describe the bug
|
||||||
|
|
||||||
|
*A clear and concise description of what the bug is.*
|
||||||
|
|
||||||
|
### Context
|
||||||
|
|
||||||
|
- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...*
|
||||||
|
- YunoHost version: x.x.x
|
||||||
|
- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...*
|
||||||
|
- Are you in a special context or did you perform some particular tweaking on your YunoHost instance ?: *no / yes*
|
||||||
|
- If yes, please explain:
|
||||||
|
- Using, or trying to install package version/branch:
|
||||||
|
- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`*
|
||||||
|
|
||||||
|
### Steps to reproduce
|
||||||
|
|
||||||
|
- *If you performed a command from the CLI, the command itself is enough. For example:*
|
||||||
|
```sh
|
||||||
|
sudo yunohost app install REPLACEBYYOURAPP
|
||||||
|
```
|
||||||
|
- *If you used the webadmin, please perform the equivalent command from the CLI first.*
|
||||||
|
- *If the error occurs in your browser, explain what you did:*
|
||||||
|
1. *Go to '...'*
|
||||||
|
2. *Click on '....'*
|
||||||
|
3. *Scroll down to '....'*
|
||||||
|
4. *See error*
|
||||||
|
|
||||||
|
### Expected behavior
|
||||||
|
|
||||||
|
*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.*
|
||||||
|
|
||||||
|
### Logs
|
||||||
|
|
||||||
|
*When an operation fails, YunoHost provides a simple way to share the logs.*
|
||||||
|
- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.*
|
||||||
|
- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.*
|
||||||
|
|
||||||
|
*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)*
|
||||||
|
|
||||||
|
*If applicable and useful, add screenshots to help explain your problem.*
|
18
pull_request_template.md
Normal file
18
pull_request_template.md
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
## Problem
|
||||||
|
- *Description of why you made this PR*
|
||||||
|
|
||||||
|
## Solution
|
||||||
|
- *And how do you fix that problem*
|
||||||
|
|
||||||
|
## PR Status
|
||||||
|
- [ ] Code finished.
|
||||||
|
- [ ] Tested with Package_check.
|
||||||
|
- [ ] Fix or enhancement tested.
|
||||||
|
- [ ] Upgrade from last version tested.
|
||||||
|
- [ ] Can be reviewed and tested.
|
||||||
|
|
||||||
|
## Package_check results
|
||||||
|
---
|
||||||
|
*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results*
|
||||||
|
|
||||||
|
[/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/REPLACEBYYOURAPP_ynh%20PR-NUM-%20(USERNAME)/)
|
|
@ -1,5 +1,12 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# COMMON VARIABLES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# dependencies used by the app
|
||||||
|
pkg_dependencies="squid3 mailutils"
|
||||||
|
|
||||||
# ============= FUTURE YUNOHOST HELPER =============
|
# ============= FUTURE YUNOHOST HELPER =============
|
||||||
# Delete a file checksum from the app settings
|
# Delete a file checksum from the app settings
|
||||||
#
|
#
|
||||||
|
@ -12,17 +19,33 @@ ynh_delete_file_checksum () {
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
ynh_app_setting_delete $app $checksum_setting_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
# Send an email to inform the administrator
|
# Send an email to inform the administrator
|
||||||
#
|
#
|
||||||
# usage: ynh_send_readme_to_admin app_message [recipients]
|
# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type]
|
||||||
# | arg: app_message - The message to send to the administrator.
|
# | arg: -m --app_message= - The file with the content to send to the administrator.
|
||||||
# | arg: recipients - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root
|
||||||
# example: "root admin@domain"
|
# example: "root admin@domain"
|
||||||
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you
|
||||||
# example: "root admin@domain user1 user2"
|
# example: "root admin@domain user1 user2"
|
||||||
|
# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade'
|
||||||
ynh_send_readme_to_admin() {
|
ynh_send_readme_to_admin() {
|
||||||
local app_message="${1:-...No specific information...}"
|
# Declare an array to define the options of this helper.
|
||||||
local recipients="${2:-root}"
|
declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= )
|
||||||
|
local app_message
|
||||||
|
local recipients
|
||||||
|
local type
|
||||||
|
# Manage arguments with getopts
|
||||||
|
|
||||||
|
ynh_handle_getopts_args "$@"
|
||||||
|
app_message="${app_message:-}"
|
||||||
|
recipients="${recipients:-root}"
|
||||||
|
type="${type:-install}"
|
||||||
|
|
||||||
|
# Get the value of admin_mail_html
|
||||||
|
admin_mail_html=$(ynh_app_setting_get $app admin_mail_html)
|
||||||
|
admin_mail_html="${admin_mail_html:-0}"
|
||||||
|
|
||||||
# Retrieve the email of users
|
# Retrieve the email of users
|
||||||
find_mails () {
|
find_mails () {
|
||||||
|
@ -48,15 +71,72 @@ ynh_send_readme_to_admin() {
|
||||||
}
|
}
|
||||||
recipients=$(find_mails "$recipients")
|
recipients=$(find_mails "$recipients")
|
||||||
|
|
||||||
local mail_subject="☁️🆈🅽🅷☁️: Yunohost \`$app\` has message for you"
|
# Subject base
|
||||||
|
local mail_subject="☁️🆈🅽🅷☁️: \`$app\`"
|
||||||
|
|
||||||
|
# Adapt the subject according to the type of mail required.
|
||||||
|
if [ "$type" = "backup" ]; then
|
||||||
|
mail_subject="$mail_subject has just been backup."
|
||||||
|
elif [ "$type" = "change_url" ]; then
|
||||||
|
mail_subject="$mail_subject has just been moved to a new URL!"
|
||||||
|
elif [ "$type" = "remove" ]; then
|
||||||
|
mail_subject="$mail_subject has just been removed!"
|
||||||
|
elif [ "$type" = "restore" ]; then
|
||||||
|
mail_subject="$mail_subject has just been restored!"
|
||||||
|
elif [ "$type" = "upgrade" ]; then
|
||||||
|
mail_subject="$mail_subject has just been upgraded!"
|
||||||
|
else # install
|
||||||
|
mail_subject="$mail_subject has just been installed!"
|
||||||
|
fi
|
||||||
|
|
||||||
local mail_message="This is an automated message from your beloved YunoHost server.
|
local mail_message="This is an automated message from your beloved YunoHost server.
|
||||||
Specific information for the application $app.
|
Specific information for the application $app.
|
||||||
$app_message
|
$(if [ -n "$app_message" ]
|
||||||
|
then
|
||||||
|
cat "$app_message"
|
||||||
|
else
|
||||||
|
echo "...No specific information..."
|
||||||
|
fi)
|
||||||
---
|
---
|
||||||
Automatic diagnosis data from YunoHost
|
Automatic diagnosis data from YunoHost
|
||||||
$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__"
|
||||||
|
|
||||||
|
# Store the message into a file for further modifications.
|
||||||
|
echo "$mail_message" > mail_to_send
|
||||||
|
|
||||||
|
# If a html email is required. Apply html tags to the message.
|
||||||
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
|
then
|
||||||
|
# Insert 'br' tags at each ending of lines.
|
||||||
|
ynh_replace_string "$" "<br>" mail_to_send
|
||||||
|
|
||||||
|
# Insert starting HTML tags
|
||||||
|
sed --in-place '1s@^@<!DOCTYPE html>\n<html>\n<head></head>\n<body>\n@' mail_to_send
|
||||||
|
|
||||||
|
# Keep tabulations
|
||||||
|
ynh_replace_string " " "\ \ " mail_to_send
|
||||||
|
ynh_replace_string "\t" "\ \ " mail_to_send
|
||||||
|
|
||||||
|
# Insert url links tags
|
||||||
|
ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "<a href=\"\2\">\1</a>" mail_to_send
|
||||||
|
|
||||||
|
# Insert pre tags
|
||||||
|
ynh_replace_string "__PRE_TAG1__" "<pre>" mail_to_send
|
||||||
|
ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
|
||||||
|
|
||||||
|
# Insert finishing HTML tags
|
||||||
|
echo -e "\n</body>\n</html>" >> mail_to_send
|
||||||
|
|
||||||
|
# Otherwise, remove tags to keep a plain text.
|
||||||
|
else
|
||||||
|
# Remove URL tags
|
||||||
|
ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
|
||||||
|
ynh_replace_string "__URL_TAG2__" ": " mail_to_send
|
||||||
|
|
||||||
|
# Remove PRE tags
|
||||||
|
ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
|
||||||
|
fi
|
||||||
|
|
||||||
# Define binary to use for mail command
|
# Define binary to use for mail command
|
||||||
if [ -e /usr/bin/bsd-mailx ]
|
if [ -e /usr/bin/bsd-mailx ]
|
||||||
then
|
then
|
||||||
|
@ -65,7 +145,13 @@ $(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')"
|
||||||
local mail_bin=/usr/bin/mail.mailutils
|
local mail_bin=/usr/bin/mail.mailutils
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Send the email to the recipients
|
if [ "$admin_mail_html" -eq 1 ]
|
||||||
echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
then
|
||||||
}
|
content_type="text/html"
|
||||||
|
else
|
||||||
|
content_type="text/plain"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Send the email to the recipients
|
||||||
|
cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
|
}
|
|
@ -31,4 +31,10 @@ squid=$(ynh_app_setting_get $app squid_folder)
|
||||||
# BACKUP OF THE CONFIG OF SQUID3
|
# BACKUP OF THE CONFIG OF SQUID3
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_backup "/etc/$squid/squid.conf"
|
ynh_backup --src_path="/etc/$squid/squid.conf"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)."
|
||||||
|
|
128
scripts/install
128
scripts/install
|
@ -26,6 +26,16 @@ ynh_abort_if_errors
|
||||||
|
|
||||||
squid_port=$YNH_APP_ARG_SQUID_PORT
|
squid_port=$YNH_APP_ARG_SQUID_PORT
|
||||||
|
|
||||||
|
### If it's a multi-instance app, meaning it can be installed several times independently
|
||||||
|
### The id of the app as stated in the manifest is available as $YNH_APP_ID
|
||||||
|
### The instance number is available as $YNH_APP_INSTANCE_NUMBER (equals "1", "2", ...)
|
||||||
|
### The app instance name is available as $YNH_APP_INSTANCE_NAME
|
||||||
|
### - the first time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample
|
||||||
|
### - the second time the app is installed, YNH_APP_INSTANCE_NAME = ynhexample__2
|
||||||
|
### - ynhexample__{N} for the subsequent installations, with N=3,4, ...
|
||||||
|
### The app instance name is probably what interests you most, since this is
|
||||||
|
### guaranteed to be unique. This is a good unique identifier to define installation path,
|
||||||
|
### db names, ...
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -33,30 +43,38 @@ app=$YNH_APP_INSTANCE_NAME
|
||||||
#=================================================
|
#=================================================
|
||||||
# FIND AND OPEN A PORT
|
# FIND AND OPEN A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Configuring firewall..."
|
||||||
|
|
||||||
### Use these lines if you have to open a port for the application
|
### Use these lines if you have to open a port for the application
|
||||||
### `ynh_find_port` will find the first available port starting from the given port.
|
### `ynh_find_port` will find the first available port starting from the given port.
|
||||||
### If you're not using these lines:
|
### If you're not using these lines:
|
||||||
### - Remove the section "CLOSE A PORT" in the remove script
|
### - Remove the section "CLOSE A PORT" in the remove script
|
||||||
|
|
||||||
# Find a free port
|
# Find an available port
|
||||||
port=$(ynh_find_port $squid_port)
|
port=$(ynh_find_port --port=$squid_port)
|
||||||
# Open this port
|
ynh_app_setting_set --app=$app --key=port --value=$port
|
||||||
yunohost firewall allow --no-upnp TCP $port 2>&1
|
|
||||||
ynh_app_setting_set $app port $port
|
# Optional: Expose this port publicly
|
||||||
|
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||||
|
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||||
|
|
||||||
|
# Open the port
|
||||||
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# INSTALL DEPENDENCIES
|
# INSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Installing dependencies..."
|
||||||
|
|
||||||
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
### `ynh_install_app_dependencies` allows you to add any "apt" dependencies to the package.
|
||||||
### Those deb packages will be installed as dependencies of this package.
|
### Those deb packages will be installed as dependencies of this package.
|
||||||
### If you're not using this helper:
|
### If you're not using this helper:
|
||||||
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
### - Remove the section "REMOVE DEPENDENCIES" in the remove script
|
||||||
|
### - Remove the variable "pkg_dependencies" in _common.sh
|
||||||
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
### - As well as the section "REINSTALL DEPENDENCIES" in the restore script
|
||||||
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
### - And the section "UPGRADE DEPENDENCIES" in the upgrade script
|
||||||
|
|
||||||
ynh_install_app_dependencies squid3 mailutils
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
|
@ -65,24 +83,25 @@ ynh_install_app_dependencies squid3 mailutils
|
||||||
### `ynh_replace_string` is used to replace a string in a file.
|
### `ynh_replace_string` is used to replace a string in a file.
|
||||||
### (It's compatible with sed regular expressions syntax)
|
### (It's compatible with sed regular expressions syntax)
|
||||||
|
|
||||||
# See is squid3 folder is there
|
# See if squid3 folder exits
|
||||||
if [ -d "/etc/squid3" ]; then
|
if [ -d "/etc/squid3" ]; then
|
||||||
squid="squid3"
|
squid="squid3"
|
||||||
|
|
||||||
# If squid3 folder is not found look for squid folder
|
# If squid3 folder is not found look for squid folder
|
||||||
elif [ -d "/etc/squid" ]; then
|
elif [ -d "/etc/squid" ]; then
|
||||||
squid="squid"
|
squid="squid"
|
||||||
|
|
||||||
# If both folders are not found then call ynh_die
|
# If both folders are not found then call ynh_die
|
||||||
else
|
else
|
||||||
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/squid.conf"
|
||||||
ynh_replace_string "__SQUID__" "$squid" "../conf/squid.conf"
|
ynh_replace_string --match_string="__SQUID__" --replace_string="$squid" --target_file="../conf/squid.conf"
|
||||||
cp -f "../conf/squid.conf" "/etc/$squid/."
|
cp -f "../conf/squid.conf" "/etc/$squid/."
|
||||||
# Save squid folder
|
# Save squid folder in app settings
|
||||||
ynh_app_setting_set $app squid_folder $squid
|
|
||||||
|
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -94,29 +113,60 @@ ynh_app_setting_set $app squid_folder $squid
|
||||||
### you can make a backup of this file before modifying it again if the admin had modified it.
|
### you can make a backup of this file before modifying it again if the admin had modified it.
|
||||||
|
|
||||||
# Calculate and store the config file checksum into the app settings
|
# Calculate and store the config file checksum into the app settings
|
||||||
ynh_store_file_checksum "/etc/$squid/squid.conf"
|
ynh_store_file_checksum --file="/etc/$squid/squid.conf"
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
### `yunohost service add` is a CLI yunohost command to add a service in the admin panel.
|
#=================================================
|
||||||
### You'll find the service in the 'services' section of YunoHost admin panel.
|
# INTEGRATE SERVICE IN YUNOHOST
|
||||||
### This CLI command would be useless if the app does not have any services (systemd or sysvinit)
|
#=================================================
|
||||||
|
ynh_script_progression --message="Integrating service in YunoHost..."
|
||||||
|
### `yunohost service add` integrates a service in YunoHost. It then gets
|
||||||
|
### displayed in the admin interface and through the others `yunohost service` commands.
|
||||||
|
### (N.B. : this line only makes sense if the app adds a service to the system!)
|
||||||
### If you're not using these lines:
|
### If you're not using these lines:
|
||||||
### - You can remove these files in conf/.
|
### - You can remove these files in conf/.
|
||||||
### - Remove the section "REMOVE SERVICE FROM ADMIN PANEL" in the remove script
|
### - Remove the section "REMOVE SERVICE INTEGRATION IN YUNOHOST" in the remove script
|
||||||
### - As well as the section ADVERTISE SERVICE IN ADMIN PANEL" in the restore script
|
### - As well as the section "INTEGRATE SERVICE IN YUNOHOST" in the restore script
|
||||||
|
### - And the section "INTEGRATE SERVICE IN YUNOHOST" in the upgrade script
|
||||||
|
|
||||||
yunohost service add squid3 --log "/var/log/$squid/access.log"
|
yunohost service add $app --description "Squid3 a web proxy service" --log "/var/log/$squid/access.log"
|
||||||
|
|
||||||
|
### Additional options starting with 3.8:
|
||||||
|
###
|
||||||
|
### --needs_exposed_ports "$port" a list of ports that needs to be publicly exposed
|
||||||
|
### which will then be checked by YunoHost's diagnosis system
|
||||||
|
### (N.B. DO NOT USE THIS is the port is only internal !!!)
|
||||||
|
###
|
||||||
|
### --test_status "some command" a custom command to check the status of the service
|
||||||
|
### (only relevant if 'systemctl status' doesn't do a good job)
|
||||||
|
###
|
||||||
|
### --test_conf "some command" some command similar to "nginx -t" that validates the conf of the service
|
||||||
|
###
|
||||||
|
### Re-calling 'yunohost service add' during the upgrade script is the right way
|
||||||
|
### to proceed if you later realize that you need to enable some flags that
|
||||||
|
### weren't enabled on old installs (be careful it'll override the existing
|
||||||
|
### service though so you should re-provide all relevant flags when doing so)
|
||||||
|
###
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTART SQUID'S SERVICE and SSOWATCONF
|
# START SYSTEMD SERVICE
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Starting a systemd service..."
|
||||||
|
### `ynh_systemd_action` is used to start a systemd service for an app.
|
||||||
|
### Only needed if you have configure a systemd service
|
||||||
|
### If you're not using these lines:
|
||||||
|
### - Remove the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the backup script
|
||||||
|
### - As well as the section "START SYSTEMD SERVICE" in the restore script
|
||||||
|
### - As well as the section"STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the upgrade script
|
||||||
|
### - And the section "STOP SYSTEMD SERVICE" and "START SYSTEMD SERVICE" in the change_url script
|
||||||
|
|
||||||
|
# Start a systemd service
|
||||||
|
ynh_systemd_action --service_name=$squid --action="start" --log_path="/var/log/$squid/access.log" --needs_exposed_ports "$port"
|
||||||
|
|
||||||
service $squid restart
|
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -124,22 +174,28 @@ yunohost app ssowatconf
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
message="You can find a config file at /etc/$squid/squid.conf
|
message="You can find a config file at /etc/$squid/squid.conf
|
||||||
Squid 3 will work with your registered users. Just put the username and password when asked.
|
Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
|
||||||
|
|
||||||
To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
|
To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
|
||||||
|
|
||||||
Enter these value in the below feilds.
|
Enter these value in the below feilds.
|
||||||
|
---------------------------------------------------------------------
|
||||||
Http proxy: your any registered domain name or ip
|
| Http proxy: Your any registered domain name or ip eg domain.tld
|
||||||
|
|--------------------------------------------------------------------
|
||||||
port: $port
|
|port: $port
|
||||||
|
|--------------------------------------------------------------------
|
||||||
Tick mark use this proxy server for all protocols
|
|Tick mark use this proxy server for all protocols
|
||||||
|
|--------------------------------------------------------------------
|
||||||
No proxy for: localhost, 127.0.0.1
|
|No proxy for: localhost, 127.0.0.1
|
||||||
|
|--------------------------------------------------------------------
|
||||||
Save and restart borwser.
|
|Save and restart borwser.
|
||||||
|
---------------------------------------------------------------------
|
||||||
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues"
|
If you are facing any issues or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues"
|
||||||
|
|
||||||
ynh_send_readme_to_admin "$message"
|
ynh_send_readme_to_admin "$message"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Installation of $app completed"
|
||||||
|
|
|
@ -12,17 +12,21 @@ source /usr/share/yunohost/helpers
|
||||||
#=================================================
|
#=================================================
|
||||||
# LOAD SETTINGS
|
# LOAD SETTINGS
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Loading installation settings..."
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
port=$(ynh_app_setting_get $app port)
|
port=$(ynh_app_setting_get $app port)
|
||||||
squid=$(ynh_app_setting_get $app squid_folder)
|
squid=$(ynh_app_setting_get $app squid_folder)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# STANDARD REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE SERVICE INTEGRATION IN YUNOHOST
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove the service from the list of services known by Yunohost (added from `yunohost service add`)
|
||||||
# Remove a service from the admin panel, added by `yunohost service add`
|
if ynh_exec_warn_less yunohost service status $app >/dev/null
|
||||||
if yunohost service status | grep -q $app
|
|
||||||
then
|
then
|
||||||
echo "Remove $squid service"
|
ynh_script_progression --message="Remove $squid service"
|
||||||
yunohost service remove $app
|
yunohost service remove $app
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -33,16 +37,31 @@ fi
|
||||||
# Remove metapackage and its dependencies
|
# Remove metapackage and its dependencies
|
||||||
apt-get -y purge squid3
|
apt-get -y purge squid3
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
ynh_remove_app_dependencies
|
||||||
#=================================================
|
#=================================================
|
||||||
# CLOSE A PORT
|
# CLOSE A PORT
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
if yunohost firewall list | grep -q "\- $port$"
|
if yunohost firewall list | grep -q "\- $port$"
|
||||||
then
|
then
|
||||||
echo "Close port $port" >&2
|
ynh_script_progression --message="Closing port $port..."
|
||||||
yunohost firewall disallow TCP $port 2>&1
|
ynh_exec_warn_less yunohost firewall disallow TCP $port
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SPECIFIC REMOVE
|
||||||
|
#=================================================
|
||||||
|
# REMOVE VARIOUS FILES
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Remove a directory securely
|
||||||
|
ynh_secure_remove --file="/etc/$squid/"
|
||||||
|
|
||||||
|
# Remove the log files
|
||||||
|
ynh_secure_remove --file="/var/log/$squid/access.log"
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# END OF SCRIPT
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
ynh_script_progression --message="Removal of $app completed"
|
||||||
|
|
|
@ -34,7 +34,7 @@ port=$(ynh_app_setting_get $app port)
|
||||||
# REINSTALL DEPENDENCIES
|
# REINSTALL DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
ynh_install_app_dependencies squid3 mailutils
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORE
|
# SPECIFIC RESTORE
|
||||||
|
@ -52,7 +52,7 @@ yunohost firewall allow --no-upnp TCP $port
|
||||||
### (It's compatible with sed regular expressions syntax)
|
### (It's compatible with sed regular expressions syntax)
|
||||||
|
|
||||||
# See is squid3 folder is there
|
# See is squid3 folder is there
|
||||||
if [ -d "/etc/squid3" ]; then
|
if [ -d "/etc/squid3" ]; then
|
||||||
squid="squid3"
|
squid="squid3"
|
||||||
# If squid3 folder is not found look for squid folder
|
# If squid3 folder is not found look for squid folder
|
||||||
elif [ -d "/etc/squid" ]; then
|
elif [ -d "/etc/squid" ]; then
|
||||||
|
@ -60,7 +60,7 @@ elif [ -d "/etc/squid" ]; then
|
||||||
# If both folders are not found then call ynh_die
|
# If both folders are not found then call ynh_die
|
||||||
else
|
else
|
||||||
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Save squid folder
|
# Save squid folder
|
||||||
|
@ -69,7 +69,7 @@ ynh_app_setting_set $app squid_folder $squid
|
||||||
#=================================================
|
#=================================================
|
||||||
# RESTORE INOTIFY'S CONFIG
|
# RESTORE INOTIFY'S CONFIG
|
||||||
#=================================================
|
#=================================================
|
||||||
ynh_secure_remove "/etc/$squid/squid.conf"
|
ynh_secure_remove "/etc/$squid/squid.conf"
|
||||||
ynh_restore_file "/etc/$squid/squid.conf"
|
ynh_restore_file "/etc/$squid/squid.conf"
|
||||||
service $squid restart
|
service $squid restart
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
@ -85,24 +85,22 @@ yunohost service add squid3 --log "/var/log/$squid/access.log"
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
message="You can find a config file at /etc/$squid/squid.conf
|
message="You can find a config file at /etc/$squid/squid.conf
|
||||||
Squid 3 will work with your registered users. Just put the username and password when asked.
|
Squid 3 will work with your registered users through LDAP. Just put the username and password when asked.
|
||||||
|
|
||||||
To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
|
To configure on Firefox go to preferences->general->network proxy->manual proxy configuration.
|
||||||
|
|
||||||
Enter these value in the below feilds.
|
Enter these value in the below feilds.
|
||||||
|
---------------------------------------------------------------------
|
||||||
Http proxy: your any registered domain name or ip
|
| Http proxy: Your any registered domain name or ip eg domain.tld
|
||||||
|
|--------------------------------------------------------------------
|
||||||
port: $port
|
|port: $port
|
||||||
|
|--------------------------------------------------------------------
|
||||||
Tick mark use this proxy server for all protocols
|
|Tick mark use this proxy server for all protocols
|
||||||
|
|--------------------------------------------------------------------
|
||||||
No proxy for: localhost, 127.0.0.1
|
|No proxy for: localhost, 127.0.0.1
|
||||||
|
|--------------------------------------------------------------------
|
||||||
Save and restart borwser.
|
|Save and restart borwser.
|
||||||
|
---------------------------------------------------------------------
|
||||||
If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues"
|
If you are facing any issues or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/squid3_ynh/issues"
|
||||||
|
|
||||||
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
ynh_send_readme_to_admin --app_message="$message" --recipients="root"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,22 @@ source /usr/share/yunohost/helpers
|
||||||
app=$YNH_APP_INSTANCE_NAME
|
app=$YNH_APP_INSTANCE_NAME
|
||||||
port=$(ynh_app_setting_get $app port)
|
port=$(ynh_app_setting_get $app port)
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# CHECK VERSION
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
### This helper will compare the version of the currently installed app and the version of the upstream package.
|
||||||
|
### $upgrade_type can have 2 different values
|
||||||
|
### - UPGRADE_APP if the upstream app version has changed
|
||||||
|
### - UPGRADE_PACKAGE if only the YunoHost package has changed
|
||||||
|
### ynh_check_app_version_changed will stop the upgrade if the app is up to date.
|
||||||
|
### UPGRADE_APP should be used to upgrade the core app only if there's an upgrade to do.
|
||||||
|
upgrade_type=$(ynh_check_app_version_changed)
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --time --weight=1
|
||||||
|
|
||||||
# Backup the current version of the app
|
# Backup the current version of the app
|
||||||
ynh_backup_before_upgrade
|
ynh_backup_before_upgrade
|
||||||
|
@ -31,21 +42,34 @@ ynh_clean_setup () {
|
||||||
# Exit if an error occurs during the execution of the script
|
# Exit if an error occurs during the execution of the script
|
||||||
ynh_abort_if_errors
|
ynh_abort_if_errors
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# DOWNLOAD, CHECK AND UNPACK SOURCE
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
if [ "$upgrade_type" == "UPGRADE_APP" ]
|
||||||
|
then
|
||||||
|
ynh_script_progression --message="Upgrading source files..." --time --weight=1
|
||||||
|
|
||||||
|
# Download, check integrity, uncompress and patch the source from app.src
|
||||||
|
ynh_setup_source --dest_dir="$final_path"
|
||||||
|
fi
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# SPECIFIC RESTORATION
|
# SPECIFIC RESTORATION
|
||||||
#=================================================
|
#=================================================
|
||||||
# REINSTALL DEPENDENCIES
|
# UPGRADE DEPENDENCIES
|
||||||
#=================================================
|
#=================================================
|
||||||
|
ynh_script_progression --message="Upgrading dependencies..." --time --weight=1
|
||||||
|
|
||||||
ynh_install_app_dependencies squid3 mailutils
|
ynh_install_app_dependencies $pkg_dependencies
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC RESTORE
|
|
||||||
#=================================================
|
|
||||||
# OPEN PORTS
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
yunohost firewall allow --no-upnp TCP $port
|
# Optional: Expose this port publicly
|
||||||
|
# (N.B. : you only need to do this if the app actually needs to expose the port publicly.
|
||||||
|
# If you do this and the app doesn't actually need you are CREATING SECURITY HOLES IN THE SERVER !)
|
||||||
|
|
||||||
|
# Open the port
|
||||||
|
ynh_exec_warn_less yunohost firewall allow --no-upnp TCP $port
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# MODIFY A CONFIG FILE
|
# MODIFY A CONFIG FILE
|
||||||
|
@ -55,9 +79,9 @@ yunohost firewall allow --no-upnp TCP $port
|
||||||
### (It's compatible with sed regular expressions syntax)
|
### (It's compatible with sed regular expressions syntax)
|
||||||
|
|
||||||
# See is squid3 folder is there
|
# See is squid3 folder is there
|
||||||
if [ -d "/etc/squid3" ]; then
|
if [ -d "/etc/squid3" ]; then
|
||||||
squid="squid3"
|
squid="squid3"
|
||||||
|
|
||||||
# If squid3 folder is not found look for squid folder
|
# If squid3 folder is not found look for squid folder
|
||||||
elif [ -d "/etc/squid" ]; then
|
elif [ -d "/etc/squid" ]; then
|
||||||
squid="squid"
|
squid="squid"
|
||||||
|
@ -65,25 +89,22 @@ elif [ -d "/etc/squid" ]; then
|
||||||
# If both folders are not found then call ynh_die
|
# If both folders are not found then call ynh_die
|
||||||
else
|
else
|
||||||
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
ynh_die "No squid folder found in /etc. Looks like squid 3 package is not installed. Try installing it manually by apt-get install squid3"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ynh_replace_string "__PORT__" "$port" "../conf/squid.conf"
|
|
||||||
ynh_replace_string "__SQUID__" "$squid" "../conf/squid.conf"
|
|
||||||
cp -f "../conf/squid.conf" "/etc/$squid/."
|
|
||||||
# Save squid folder
|
|
||||||
ynh_app_setting_set $app squid_folder $squid
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
|
||||||
# SPECIFIC UPGRADE
|
|
||||||
#=================================================
|
|
||||||
|
|
||||||
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
### Verify the checksum of a file, stored by `ynh_store_file_checksum` in the install script.
|
||||||
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
### And create a backup of this file if the checksum is different. So the file will be backed up if the admin had modified it.
|
||||||
ynh_backup_if_checksum_is_different "/etc/$squid/squid.conf"
|
ynh_backup_if_checksum_is_different --file="/etc/$squid/squid.conf"
|
||||||
|
|
||||||
|
ynh_replace_string --match_string="__PORT__" --replace_string="$port" --target_file="../conf/squid.conf"
|
||||||
|
ynh_replace_string --match_string="__SQUID__" --replace_string="$squid" --target_file="../conf/squid.conf"
|
||||||
|
cp -f "../conf/squid.conf" "/etc/$squid/."
|
||||||
|
# Save squid folder
|
||||||
|
ynh_app_setting_set --app=$app --key=squid_folder --value=$squid
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Recalculate and store the checksum of the file for the next upgrade.
|
# Recalculate and store the checksum of the file for the next upgrade.
|
||||||
ynh_store_file_checksum "/etc/$squid/squid.conf"
|
ynh_store_file_checksum --file="/etc/$squid/squid.conf"
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# ADVERTISE SERVICE IN ADMIN PANEL
|
# ADVERTISE SERVICE IN ADMIN PANEL
|
||||||
|
@ -105,4 +126,3 @@ yunohost service add squid3 --log "/var/log/$squid/access.log"
|
||||||
|
|
||||||
service $squid restart
|
service $squid restart
|
||||||
yunohost app ssowatconf
|
yunohost app ssowatconf
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue