mirror of
				https://github.com/hiskang/acme.sh
				synced 2025-10-30 18:07:15 +00:00 
			
		
		
		
	Merge pull request #967 from Neilpang/dev
support fcrontab, fix https://github.com/Neilpang/acme.sh/issues/966
This commit is contained in:
		
						commit
						90100aa169
					
				
							
								
								
									
										33
									
								
								acme.sh
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								acme.sh
									
									
									
									
									
								
							| @ -4417,15 +4417,19 @@ _installcert() { | |||||||
| installcronjob() { | installcronjob() { | ||||||
|   _c_home="$1" |   _c_home="$1" | ||||||
|   _initpath |   _initpath | ||||||
|   if ! _exists "crontab"; then |   _CRONTAB="crontab" | ||||||
|     _err "crontab doesn't exist, so, we can not install cron jobs." |   if ! _exists "$_CRONTAB" && _exists "fcrontab"; then | ||||||
|  |     _CRONTAB="fcrontab" | ||||||
|  |   fi | ||||||
|  |   if ! _exists "$_CRONTAB"; then | ||||||
|  |     _err "crontab/fcrontab doesn't exist, so, we can not install cron jobs." | ||||||
|     _err "All your certs will not be renewed automatically." |     _err "All your certs will not be renewed automatically." | ||||||
|     _err "You must add your own cron job to call '$PROJECT_ENTRY --cron' everyday." |     _err "You must add your own cron job to call '$PROJECT_ENTRY --cron' everyday." | ||||||
|     return 1 |     return 1 | ||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
|   _info "Installing cron job" |   _info "Installing cron job" | ||||||
|   if ! crontab -l | grep "$PROJECT_ENTRY --cron"; then |   if ! $_CRONTAB -l | grep "$PROJECT_ENTRY --cron"; then | ||||||
|     if [ -f "$LE_WORKING_DIR/$PROJECT_ENTRY" ]; then |     if [ -f "$LE_WORKING_DIR/$PROJECT_ENTRY" ]; then | ||||||
|       lesh="\"$LE_WORKING_DIR\"/$PROJECT_ENTRY" |       lesh="\"$LE_WORKING_DIR\"/$PROJECT_ENTRY" | ||||||
|     else |     else | ||||||
| @ -4439,15 +4443,15 @@ installcronjob() { | |||||||
|     _t=$(_time) |     _t=$(_time) | ||||||
|     random_minute=$(_math $_t % 60) |     random_minute=$(_math $_t % 60) | ||||||
|     if _exists uname && uname -a | grep SunOS >/dev/null; then |     if _exists uname && uname -a | grep SunOS >/dev/null; then | ||||||
|       crontab -l | { |       $_CRONTAB -l | { | ||||||
|         cat |         cat | ||||||
|         echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null" |         echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null" | ||||||
|       } | crontab -- |       } | $_CRONTAB -- | ||||||
|     else |     else | ||||||
|       crontab -l | { |       $_CRONTAB -l | { | ||||||
|         cat |         cat | ||||||
|         echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null" |         echo "$random_minute 0 * * * $lesh --cron --home \"$LE_WORKING_DIR\" $_c_entry> /dev/null" | ||||||
|       } | crontab - |       } | $_CRONTAB - | ||||||
|     fi |     fi | ||||||
|   fi |   fi | ||||||
|   if [ "$?" != "0" ]; then |   if [ "$?" != "0" ]; then | ||||||
| @ -4459,16 +4463,21 @@ installcronjob() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uninstallcronjob() { | uninstallcronjob() { | ||||||
|   if ! _exists "crontab"; then |   _CRONTAB="crontab" | ||||||
|  |   if ! _exists "$_CRONTAB" && _exists "fcrontab"; then | ||||||
|  |     _CRONTAB="fcrontab" | ||||||
|  |   fi | ||||||
|  | 
 | ||||||
|  |   if ! _exists "$_CRONTAB"; then | ||||||
|     return |     return | ||||||
|   fi |   fi | ||||||
|   _info "Removing cron job" |   _info "Removing cron job" | ||||||
|   cr="$(crontab -l | grep "$PROJECT_ENTRY --cron")" |   cr="$($_CRONTAB -l | grep "$PROJECT_ENTRY --cron")" | ||||||
|   if [ "$cr" ]; then |   if [ "$cr" ]; then | ||||||
|     if _exists uname && uname -a | grep solaris >/dev/null; then |     if _exists uname && uname -a | grep solaris >/dev/null; then | ||||||
|       crontab -l | sed "/$PROJECT_ENTRY --cron/d" | crontab -- |       $_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB -- | ||||||
|     else |     else | ||||||
|       crontab -l | sed "/$PROJECT_ENTRY --cron/d" | crontab - |       $_CRONTAB -l | sed "/$PROJECT_ENTRY --cron/d" | $_CRONTAB - | ||||||
|     fi |     fi | ||||||
|     LE_WORKING_DIR="$(echo "$cr" | cut -d ' ' -f 9 | tr -d '"')" |     LE_WORKING_DIR="$(echo "$cr" | cut -d ' ' -f 9 | tr -d '"')" | ||||||
|     _info LE_WORKING_DIR "$LE_WORKING_DIR" |     _info LE_WORKING_DIR "$LE_WORKING_DIR" | ||||||
| @ -4745,7 +4754,7 @@ _precheck() { | |||||||
|   fi |   fi | ||||||
| 
 | 
 | ||||||
|   if [ -z "$_nocron" ]; then |   if [ -z "$_nocron" ]; then | ||||||
|     if ! _exists "crontab"; then |     if ! _exists "crontab" && ! _exists "fcrontab"; then | ||||||
|       _err "It is recommended to install crontab first. try to install 'cron, crontab, crontabs or vixie-cron'." |       _err "It is recommended to install crontab first. try to install 'cron, crontab, crontabs or vixie-cron'." | ||||||
|       _err "We need to set cron job to renew the certs automatically." |       _err "We need to set cron job to renew the certs automatically." | ||||||
|       _err "Otherwise, your certs will not be able to be renewed automatically." |       _err "Otherwise, your certs will not be able to be renewed automatically." | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user